views:

59

answers:

1

So I have several viewControllers, each creates images using "imageWithContentsOfFile" in order to conserve memory and then sets objects to nil and releases them in the dealloc method. There are no memory leaks. The problem is memory still builds up when switching views. So for example I'll be in view1 and it'll be using 8MB of memory and then I'll switch to view2 and back to view1 again and it'll be now using 10MB of memory. I've checked allocations in instruments and it's the images using it. Is there something I need to do to flush the memory out or something?

Thanks in advance!

A: 

Shouldn't you be calling [object release] before setting object = nil?

Sorry, I'm at home and I don't have a mac here so I can't test what happens when you do it the other way around.

Also, by saying there are no leaks, did you check using the Leaks tool? I don't think the tool detects all leaks, as I've tried putting a leak on purpose but Leaks wasn't able to see it.

Altealice
Yes, setting object to nil and then releasing it will result in releasing nil, which does nothing. If that's what he's doing that'd be the problem.
Kalle