objective c – How to find a variable if I have its address in memory? – Education Career Blog

in my application I am getting an exception: MyApp(38431,0xa004ffa0) malloc: *** error for object 0xa08be760: pointer being freed was not allocated

Is there a way for XCode to show me where this pointer is? How can I find where the problem is?

I know that I can type info line*address and it may show me where the line is. But now it doesn’t work for me.

How can I get a number of line or name of a variable where exception is being thrown?

Thank you in advance,


You’re calling free() without calling malloc(). Look for uninitialized pointers. If you’re using a debugger (gdb) you should be able to type “bt” for “backtrace” and this will show you the stack at the time the error occurs.


in gdb try


to get more information about when the error happens. Attempting to free non allocated memory is a common bug and gdb+xcode provides many tools to help you figure out where the problem is.


You should be able to put a breakpoint a malloc_error this will cause your program to break when the message in question is printed.

You can also use the following method, to find the point of allocation from the address:

  1. Set MallocStackLogging, MallocStackLoggingNoCompact environments to 1.
  2. Run the program and once it prints out the line use malloc_history from shell to find out the stack trace of the allocation: malloc_history <pid> <addr>.

Leave a Comment