IPhone - debug "release the pointer, there was no release"

When you free the pointer, you may see an error, for example

"freed pointer was not assigned

When debugging with the simulator, I add the argument to build MallocStackLogging = YES - this allows me to use malloc_history in the terminal to track where I already freed the pointer.

If I debug the device using this build argument, I get all kinds of console errors such as โ€œunable to create stack log filesโ€, etc.

Oddly enough, I get some freed pointer errors appearing on the device, but not on the simulator.

Does anyone have any sensations related to this using the device itself?

Thanks!

+6
iphone cocoa-touch
source share
4 answers

Another way to do it. Make sure NSZombie is turned on, so it reports the memory address of the object that receives the additional release. Then run using the Performance Tool-> Object Allocations. This will trigger the tools. Take a look at the console log provided by the Xcode organizer. As soon as you get a crash search for a memory address in tools. You will see the whole history of mallocs / frees on this object, as well as links directly to your code.

+9
source share

I usually use NSZombie for such things, check this out

+1
source share

You need to set the env variables for MallocStackLogging in the target executable ...

To access these settings, select the executable from the Groups and Files panel in Xcode, then click Get Information.

Go to the "Arguments" tab and add the following entries to the "Variables that should be set in the environment" field:

0
source share

Please check the program for memory leak. Also check autoreleads and whether you are submitting objects correctly or not. We also need to check if the allocated memory object is allocated or not. In addition, you need to be careful about auto-advertising, because by chance we can free an array or string or any object that is already auto-implemented ... I hope this helps and works!

Tip. You can test leaks by analyzing your project (click shift + command + k)

0
source share

All Articles