Advice on fixing memory leaks

Apprentice
Posts: 6
Joined: 2009.07
Post: #1
Hi,

I'm trying to resolve some memory leaks that are crashing an iPhone game I've created, but having only been working in Objective C for a year - learnt for this project - I'm finding my lack of experience is really slowing me down at the debug stage. Coming from a low-end PHP web server side of coding, I realise I've been rather spoilt / lazy when it came to worrying about how much memory I have, so this has been enlightening, to say the least Wink

Can anyone suggest some good online tutorials / guides that might help me debug my app. better as far as memory leaks etc. are concerned, and how to be sure I have properly freed up memory when possible / necessary? So far I haven't found the 'killer' article which finally makes sense of it all for me. I feel like I'm missing something fundamental, something obvious about the whole thing.

Anyway guidance appreciated, thanks for your time.

Pete
Moderator
Posts: 3,579
Joined: 2003.06
Post: #2
Have you tried using Instruments?
Apprentice
Posts: 6
Joined: 2009.07
Post: #3
Yes, using Instruments, and currently working with this article:

http://www.mobileorchard.com/find-iphone...-tutorial/

which has certainly opened some doors, but isn't quite joining all the dots when I apply to my code ...

I think the real problem is I still don't fully understand memory management. I really am a total noob in this sort of structured environment. My game is very simple and I know I've spent most of the last year simply getting to grips with the platform rather than my little project. And this (memory management) is one more aspect that I need to get a handle on ...

Anyway, yes, using Instruments, starting to get an idea how to not just check for leaks but also then track down the reason, but only a very vague idea ...

Looking for guidance on how to use Instruments to fix leaks, I suppose Smile

Forgive my rambling.

Pete
Moderator
Posts: 133
Joined: 2008.05
Post: #4
Memory management is a tough concept to truly to explain to people, and unfortunately can't be covered by a few unedited blog posts.

To get you started, there are some good tools built into the development environment for this: Instruments and the Static Analyzer. You can run either the ObjectAlloc or Leaks instrument by choosing them from the Run->Run with Performance Tool in Xcode. You can also choose Build and Analyze from the Build menu to see if the static analyzer catches anything.

But, if you truly want to understand memory management, you will probably have to fork over the money for a book. For Objective-C, people seem to like Stephen Kochan's Programming in Objective-C.

If you want something more iPhone-centric that includes coverage of using Instruments, I'll go ahead and plug our book, which, without bias, is very good. That link is in my signature.
Apprentice
Posts: 6
Joined: 2009.07
Post: #5
Hi,

I appreciate your input. I'll take a look at the books then ... I was beginning to swing that way anyway, so good to have some recommendations.

Pete
Thread Closed 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  does the app store accept games with leaks? aerospaceman 5 6,393 Mar 15, 2011 01:59 PM
Last Post: aerospaceman
  Looking for some insight while fixing leaks... agreendev 2 3,289 Sep 28, 2010 11:57 AM
Last Post: agreendev
  Leaks program kendric 2 2,980 Jun 16, 2009 08:19 PM
Last Post: kendric
  Leaks in the waterworks. bmantzey 5 3,839 Feb 27, 2009 04:07 PM
Last Post: AnotherJake