PDA

View Full Version : How to know what objects are released at a certain time




99miles
Apr 22, 2009, 08:21 PM
I've been fine-tuning my app with ObjectAlloc, watching the allocations as I use my app. I found that there are a couple things I can do that decrease the allocations shown in the trace panel of Instruments:ObjectAlloc from 1.3Mb to 0.744Mb. The drop is completely vertical, so it all happens at once. I can't seem to figure out what is getting dropped. I'm trying to figure out what it is to see if I can start the app out running at 0.75Mb instead of 1.3Mb.

There are 2 ways I can make it happen.
1) One is to click on the button that opens my apps preferences, which is a Navigation Controller. The base view isn't getting unloaded, so it's not that. The only thing that happens when I open this preferences view is I add it to the window:

UIView *v = [[viewControllerManager objectAtIndex:viewToLoad] view];
[ window addSubview:v ];

2) The other way is to simply hit my 'New game' button which simply clears the board and start anew. BUT, it only happens on the 3rd or 4th time, never before.
This makes me pretty convinced is something going on behind the scenes, and not something my code is explicitely doing.

I know it could be hard to know from just that info, but does anyone have a clue what could be causing this? Or any hints on how to see what objects are getting dropped between two given moments in time?

Thanks so much



BlackWolf
Apr 23, 2009, 12:24 AM
well, I used objectAlloc a few times and I have to say it sometimes produces really unexpected results. you never know how cocoa touch behaves behind the scenes. My guess is that in both cases some visible resources are freed or something, but you can't know.

the really important thing is that you do your memory managment correctly. also, when you load a new view you might want to unload (removeFromSuperview) the one that is currently one the screen. I don't know if that helps, since I guess the view still has to be kept in memory (since it's still in your navigation controller), but you could try if it does something.