NSData release is not reclaiming memory
- by ctpenrose
iPhoneOS 3.2
I use NSKeyedUnarchiver's unarchiveObjectWithFile: to load a custom object that contains a single large NSData and another much smaller object. The dealloc method in my custom object gets called, the NSData object is released, its retainCount == 1 just before. Physical memory does not decrement by any amount, let alone a fraction of the NSData size, and with repetition memory warnings are reliably generated: I have test until I actually received level 2 warnings. =(
NSString *archivePath = [[[NSBundle mainBundle] pathForResource:@"lingering"]
ofType:@"data"] retain];
lingeringDataContainer = [[NSKeyedUnarchiver unarchiveObjectWithFile:archivePath] retain];
[archivePath release];
[lingeringDataContainer release];
and now the dealloc....
- (void) dealloc {
[releasingObject release];
[lingeringData release];
[super dealloc];
}
Before release:
(gdb) p (int) [(NSData *) lingeringData retainCount]
$1 = 1
After:
(gdb) p (int) [(NSData *) lingeringData retainCount]
Target does not respond to this message selector.