I got this error when using my app (under ARC)
(816,0x2ffe0000) malloc: *** error for object 0xb185010: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
So I set a malloc_error_break breakpoint and did not get any additional information to the console. I add bt to the console and get
(gdb) bt
#0 0x3635117c in malloc_error_break ()
#1 0x362dd924 in free ()
#2 0x31d64588 in -[NSConcreteData dealloc] ()
#3 0x319a50c4 in _objc_rootRelease ()
#4 0x319a6db6 in objc_release ()
#5 0x319a5e0c in (anonymous namespace)::AutoreleasePoolPage::pop ()
#6 0x319a5d28 in _objc_autoreleasePoolPop ()
#7 0x37e13e8e in _CFAutoreleasePoolPop ()
#8 0x37b818e6 in _dispatch_worker_thread2 ()
#9 0x362e61ce in _pthread_wqthread ()
#10 0x362e60a4 in start_wqthread ()
The error appears at different time, different usage and I cannot find the code involve. Any idea how to debug (only on device, I use AVCaptureSession).
Edit
I think it comes from
NSData *data = [NSData dataWithBytesNoCopy:cvMat.data
length:(cvMat.elemSize() * cvMat.total())
freeWhenDone:YES];
CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
With this code, I constraint memory allocation
Whereas if I change it to
NSData *data = [NSData dataWithBytes:cvMat.data
length:(cvMat.elemSize() * cvMat.total())];
CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
I got something strange which looks like an AutoReleasePool
Could the error be due to autoreleasing of one of the object in the code ?
*method taken from Robin Summerhill