views:

60

answers:

1

An application that I am developing retains several WebViews that are used to allow an embedded web browsing experience for some activities centralized around the application. The problem that I am having is that after several hours open and after a lot of use the views begin to build up memory. My understanding of the memory management in Objective-C is that once and object is released entirely (retain count = 0) and is deallocated the amount of memory used by the application as a whole goes down. This does not seem to be applying to my situation.

[webviewObject release];
webviewObject = nil;

webviewObject = [[self createNewViewWithName:name] retain];

The above is the code that I am using. I have tried releasing the memory and not creating a new instance but to no luck. Memory usage simply continues to grow and according to Instruments the objects are released entirely. Am I missing something? Could the application be caching some how?

A: 

If Instruments says they're released but the memory footprint is growing, you're most definitely using NSZombies.

In your application didStart method's top, put this in and you'll be a happier wo/man forever:

if (getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled")) {
    NSLog(@"\n***\n*** NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!\n***\n\n");
} else {
    NSLog(@"\n*** No NSZombieEnabled or NSAutoreleaseFreedObjectCheckEnabled\n");
}

If that goes "No NSZombieEnabled" something else is the problem.

Kalle