4

Please suggest the best way of solving memory leaks on the iphone. What is the best use of release, autorelease, retain and which cases do each apply?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Hiren Gujarati
  • 1,039
  • 14
  • 32

4 Answers4

6

You can track memory leaks with Instruments: see this tutorial.

If you're familiar with Valgrind, you use it on x86 binaries built against the iPhone Simulator SDK: see how Landon Fuller does it.

EDIT: Another Stackoverflow answer suggests the Clang analyser: static analysis of the code may detect memory allocation errors as well. I never used this tool myself but it's good to know it's possible.

Community
  • 1
  • 1
Gregory Pakosz
  • 69,011
  • 20
  • 139
  • 164
1

There's Apple's Instruments.app in your /Developer/Applications folder, which is intended to test appplications for leaks and other errors.

I believe you will find a good tutorial.

Jacek
  • 1,894
  • 5
  • 21
  • 34
0

Also see Apple's Introduction to Instruments User Guide.

jww
  • 97,681
  • 90
  • 411
  • 885