Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect stuff that has not been released properly

Writing a program for the iphone. Realized that I forgot to release an object, but there was really no indication that the object was not released everything just worked.

What is the best way to track something like this down? Is there a way to see what objects still exist in memory when the program exits out?

like image 408
Mel Avatar asked Nov 28 '22 12:11

Mel


2 Answers

Take a look at the Leaks tool in Instruments.

like image 112
highlycaffeinated Avatar answered Dec 06 '22 00:12

highlycaffeinated


Strictly speaking, when the program exits, it doesn’t matter what you’ve left in memory: the system frees everything that your application allocated throughout its lifetime. Since iOS 4, though, apps usually just get frozen in the background and don’t exit until the system kills them to free up memory. To avoid that—and to reduce your app’s memory footprint, which is important while it’s running—you should, as highlycaffeinated and Daniel suggested, use Instruments’s Leaks tool to check for objects that aren’t getting deallocated properly.

like image 38
Noah Witherspoon Avatar answered Dec 06 '22 00:12

Noah Witherspoon