How to detect material that has not been released properly

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

What's the best way to track something like that? Is there a way to see which objects still exist in memory when the program exits?

+4
source share
5 answers

Look at the Leak Tool in Tools .

+12
source

Strictly speaking, when the program exits, it does not matter what you left in the memory: the system releases everything that your application has been distributing throughout its life. With iOS 4, however, applications usually just freeze in the background and don't exit until the system kills them to free up memory. To avoid this, and to reduce the memory size of applications, which is important when starting it, you should, like the above, use Daniel Tools to verify that objects that arent getting properly freed

+6
source

When the application exits, everything in memory is destroyed by the system (it is not freed, but simply destroyed when the address space is returned to the system).

While others suggested using the Leaks tool to find leaks in your application, Leaks will not find many different types of memory. If the object is selected, somewhere it is pushed into the cache somewhere, then the key to this object in the cache is lost, the object leaks efficiently (it cannot be used again), but will not be found by leaks, because it is still connected to your viable graphic object .

The best bet is to use Heapshot analysis to see how the graph of your application is growing. I wrote a tutorial using Heapshot analysis that may be useful to you.

If you want to capture a snapshot before your application exits, put sleep(1000); in your code either in the application completion handler, or in another place that runs immediately before the application exits.

Remember to remove it before submitting the assembly. :)

+5
source

Once the application shuts down, you do not have access to it. But tools (Xcode tool) can look for memory leaks.

+3
source

Nothing exists in memory when pprogram exits. But you can start by analyzing the code (Product → Analyze) and running it using (Product → Profile) Allocation or Leaks in Instruments to find memory management problems.

+3
source

All Articles