views:

20

answers:

1

Hi, I have noticed a strange behavior when adding and removing UIViewControllers I dont post for now any example,I have some view controllers that load their view from a xib and others that i create the view manually.(Do i have to declare Outlets for every element created in IB?even those that are static graphics?or does deallotion happen automatically as the allocation?) What i seem to notice is that even though i'm removing the view controllers view and then release the controller,the allocation(live bytes) in instruments doesnt seem to go down.Dealloc is being called every time.The next time i create the view controller the live bytes stay the same.As if they where previously not freed but remain cached.The thing is that i have several of them handling views that are intense? in graphics,but not all of them in the same time..and the bytes add up.It goes to about 15Mb of memory(while the app starts ta 3 and most of the time thats all that it would need).I also checked some of apples examples and i noticed sometimes the same behavior.Is it something i'm missing? Maybe its something i am doing wrong in particular,so i should post some code to examine what could be wrong? Thanks

+1  A: 

First of all check your code for memory leaks (with leaks tool) and run "build and analyze" on your project - may be static analyzer can spot some problems.

The second thing to check is if you're releasing controller's outlets in its dealloc method: when loaded from xib files outlets are retained by default if no property defined for them or if there's a property with 'retain' attribute. So if you don't release them they must leak then I think (although instruments did not show any leaks for that case when I had similar issue)

Vladimir
no leaks are detected,forgot to mention that..and also analyze didnt say anything interesting except from some unused vars..my main questions remains if it could some kind of caching?because reallocating doesn't seem to take up any other ram
tasos
just found this on a post When you load a nib file that contains references to image and sound resources, the nib-loading code caches resources whenever possible for easy retrieval later. For example, after loading a nib file, you can retrieve an image associated with that nib file using the imageNamed: method of either NSImage or UIImage (depending on your platform).So i guess this could be it ,since my xibs mostly contain images,or buttons with custom images etc!
tasos