Why does this method without fail produce a "malloc_error_break" every run?
I have a method that I use to retrieve data from a plist that looks like
this:
The method itself is this:
//'path' is of the form "beach.color.green" (for example)
-(NSString *)elementWithPath: (NSString *)path {
//'self.target' is the path to the plist
NSDictionary *currentData = [NSDictionary
dictionaryWithContentsOfFile:self.target];
//This is the number of nested layers that the desired data lies in.
NSUInteger numberOfLayers = [[path componentsSeparatedByString:@"."]
count];
for(NSUInteger i = 0; i < numberOfLayers; i++) {
NSString *pathComponentInCurrentLayer = [path
componentsSeparatedByString:@"."][i];
//If the data we're currently searching through is a dictionary...
if([[currentData objectForKey:pathComponentInCurrentLayer]
isKindOfClass:[NSDictionary class]])
//Narrow our search by making that dictionary the dictionary
to search through
currentData = [currentData
objectForKey:pathComponentInCurrentLayer];
//It's not a dictionary, so it has to be the desired data...
else
//So we return it
return [currentData objectForKey:pathComponentInCurrentLayer];
}
return nil;
}
I know the method works fine because I stepped through it with breakpoints
and verified that it returned the proper output. The thing is, every time
I run my project (in which this method is called many, many times), I get
the following error:
PSIslandTerrainGenerator(29202,0x1eb3a28) malloc: * mmap(size=2097152)
failed (error code=12)
* error: can't allocate region * set a breakpoint in malloc_error_break to
debug PSIslandTerrainGenerator(29202,0x1eb3a28) malloc: *
mmap(size=2097152) failed (error code=12)
* error: can't allocate region * set a breakpoint in malloc_error_break to
debug PSIslandTerrainGenerator(29202,0x1eb3a28) malloc: *
mmap(size=2097152) failed (error code=12)
* error: can't allocate region * set a breakpoint in malloc_error_break to
debug PSIslandTerrainGenerator(29202,0x1eb3a28) malloc: *
mmap(size=2097152) failed (error code=12)
* error: can't allocate region * set a breakpoint in malloc_error_break to
debug PSIslandTerrainGenerator(29202,0x1eb3a28) malloc: *
mmap(size=2097152) failed (error code=12)
* error: can't allocate region * set a breakpoint in malloc_error_break to
debug 2013-08-26 19:01:15.644 PSIslandTerrainGenerator[29202:a0b]
beach.upper_elevation_threshold PSIslandTerrainGenerator(29202,0x1eb3a28)
malloc: * mmap(size=2097152) failed (error code=12)
* error: can't allocate region * set a breakpoint in malloc_error_break to
debug 2013-08-26 19:01:15.647 PSIslandTerrainGenerator[29202:a0b]
low_grass.upper_elevation_threshold
PSIslandTerrainGenerator(29202,0x1eb3a28) malloc: * mmap(size=2097152)
failed (error code=12)
* error: can't allocate region * set a breakpoint in malloc_error_break to
debug
I went into Instruments and analyzed the app, and it showed that whenever
it crashes the app is using upwards of 3 gigabytes of memory. So I'm
guessing that something in this method fails to be released every time it
is run, but can't pinpoint exactly what.
No comments:
Post a Comment