Re: Error with malloc and NSFileWrapper
Re: Error with malloc and NSFileWrapper
- Subject: Re: Error with malloc and NSFileWrapper
- From: Quincey Morris <email@hidden>
- Date: Thu, 18 Dec 2008 10:47:13 -0800
On Dec 17, 2008, at 17:22, Guillaume Campagna wrote:
I'm using a NSDirectoryEnumerator to add all the content of a folder
to some array... I'm filtering these files (I don't want certains
types of files). One of these file types is symbolic link (alias).
So I'm using NSFileWrapper to check that with -(BOOL) isRegularFile.
After that I'm including these array to an custom object.
The problem is : when I include the FileWrapper code, it does not
work. It gives me this error :
RFM(52227,0xa0182720) malloc: *** mmap(size=28672) failed (error
code=12)
RFM(52227,0xa0182720) malloc: *** error: can't allocate region
RFM(52227,0xa0182720) malloc: *** set a breakpoint in
malloc_error_break to debug
If I do not include the code, it works like this part of the code... :
//if([[[NSFileWrapper alloc] initWithPath:path] isRegularFile]) {
//Don't want nib resources and add it to the dictionnary
if ([fileType isEqualToString:@"nib"]) {
[resourcesArray addObject:[pathResourcesName lastPathComponent]];
[fullPathsArray addObject:pathResourcesName];
[resourcesNum skipDescendents];
}
//Nor these types of files
else if (([fileType isEqualToString:@"t2t"]) ||
([fileType isEqualToString:@"html"]) ||
([fileType isEqualToString:@"helpindex"]) ||
([fileType isEqualToString:@"css"]) ||
([fileType isEqualToString:@"mpkg"]) ||
([fileType isEqualToString:@"pkg"]) ||
([fileType isEqualToString:@"strings"]) ||
([fileType isEqualToString:@"plist"]) ||
([fileType isEqualToString:@"txt"]) ||
([fileType isEqualToString:@"app"]))
[resourcesNum skipDescendents];
else if (([fileType isEqualToString:@""]) ||
([fileType isEqualToString:@"lproj"]));
else {
[resourcesArray addObject:[pathResourcesName lastPathComponent]];
[fullPathsArray addObject:pathResourcesName];
}
//}
The error suggests that you're running out memory (or, more
specifically, VM address space).
If this is NOT a garbage-collected application, you're leaking a
NSFileWrapper every time through this code. (You created it, so you
own it, so you must release it.) You could fix that by arranging to
release the NSFileWrapper after you're done with it.
If this is a garbage-collected application, and you're in a tight loop
over a lot of files, the garbage collector may not be getting a chance
to run. You could fix that by calling collectIfNeeded periodically
during the loop.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden