• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AS, ASS, Cocoa, Call Method and memory troubles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AS, ASS, Cocoa, Call Method and memory troubles


  • Subject: AS, ASS, Cocoa, Call Method and memory troubles
  • From: Hagimeno <email@hidden>
  • Date: Mon, 11 Jan 2010 13:29:56 +0000 (GMT)

Hi,
I have built an AS application that gets some value from the Entourage application, puts it into an “array/named-fields” structure and sends it to my friend’s Cocoa routine through the “call method” (see the routine here below). The Cocoa input value is an (NSMutableDictionary*) which, as I know, should be a mere pointer to my array, so it should be just 4 bytes long.  I call this Cocoa routine from within a loop in my AS, and sometimes, the size of the dictionary (the parameter “record”) I send to the Cocoa routine could be big up to 100MB.
The Cocoa routine has its own autorelease pool. Anyway when I call this routine from within my AS loop, the memory footprint of my AS app grows and grows up to 1GB until my app crashes. If I don’t include this 100MB object in the dictionary, the apps never crashes and the memory never grows. So I presume there should be a lack of memory somewhere. So my questions are:

How can I avoid the crash?
Why does the memory grow and grow?
Does AS sends a copy of the dictionary to the Cocoa routine?
Shouldn’t the parameter passed be a mere pointer and not a copy of the 100MB dictionary?


- (BOOL)WriteData:(NSMutableDictionary*)record toPath:(NSString*)filePath
{
BOOL written = NO;

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSFileManager       *manager = [NSFileManager defaultManager];
NSString                *parentFolder = [filePath stringByDeletingLastPathComponent];

BOOL isDir = NO;
BOOL parentExists = [manager fileExistsAtPath:parentFolder isDirectory:&isDir];
if(parentExists && isDir == NO) goto bail;

if(!parentExists){
    parentExists = [manager createDirectoryAtPath:parentFolder withIntermediateDirectories:YES attributes:nil error:nil];
    if(!parentExists) goto bail;
   }

    written = [record writeToFile:filePath atomically:YES];
    [record removeAllObjects];

bail:
    [pool release];

    return written;
}

Alex and Steve




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Select folder, make new folder in same directory...
  • Next by Date: ICC Profile Name
  • Previous by thread: Re: Select folder, make new folder in same directory...
  • Next by thread: Re: AS, ASS, Cocoa, Call Method and memory troubles
  • Index(es):
    • Date
    • Thread