i am writing a iPad application and displaying the tableView in my application. I have two options in tableview:
includeAll
ExcludeAll
Once i click the IncludeAll all cells should be selected. I am loading more then 10000 records. once i select the include all i got one error message.
error message is
malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Googling will reveal quite a few tutorials on using instruments to understand what is going on with your memory:
How to debug memory leaks: (tutorial)
http://www.raywenderlich.com/2696/how-to-debug-memory-leaks-with-xcode-and-instruments-tutorial
And another:
Finding Obj-C memory leaks (video)
http://www.youtube.com/watch?v=R449qEuexNs&feature=related
Probably because your simulator is able to allocate ~500Mb of memory while your iPad is not able to do it. I think you should rethink what you are doing
do you really need so much memory?
isn't it just a calculating bug? (maybe a wrong sizeof or whatever)
in any case this is really too much data to be handled
Related
Application was terminated due to memory issue
I was expecting only solution.Please help if anyone knows the solution.I have tried pagination but due to high quality of images images are stuck on table view
My app is sometimes crashing and the console says
Message from debugger: Terminated due to memory issue
Has anyone else experienced this and know some of what can cause this? Here is what I have tried so far.
I have enabled Zombie Objects and it does not find anything.
This only happens on my iPhone and so I can't run the other Memory Management tools that only run on the simulator (ie Guard Malloc).
This only happens after a low memory warning. It doesn't happen after every memory warning, just after some memory warnings. When my app receives a memory warning, it clears out a number of caches and so my guess is that it is related to this.
In the simulator I simulated memory warnings and this never happened.
I thought that it might be related to a weak object so I added a symbolic break point on objc_weak_error. I did get the debugger to stop one this break point once and I fixed the weak error, but it did not fix the "Terminated due to memory issue".
I though that maybe I wasn't freeing up enough memory, so I watched the total memory used by my app in Xcode and it never went over 50% of available memory.
My app is a mixture of Objective-C and Swift code. It appears that this is coming from areas of my app that are written in Objective-C, but I am not 100% sure.
I would love to know if anyone else has experienced this issue and if so what you did to fix it. I have looked at the other Stack Overlow issues on this and so far none of them have given me any extra insight to this problem.
So one of my initial observations was wrong. I thought that my app never went above 50% of available memory (point 6 above). I was wrong. It did use up more memory and this error is coming because I did not release enough memory during the memory warning.
I was reading a really large file into memory on the main thread (not just the simple dataWithContentsOfFile: method, I was also doing some data manipulation), and my app crashed. After I moved this process to a background thread, the app doesn't crash anymore. The only thing that happens is that the NSData I get is nil.
Is it possible that only my background thread is interrupted without affecting the main thread, or am I missing something? Also, can I count on this behaviour and just display an error message when the NSData is nil, without the app to crash? Thank you in advance.
Edit:
The log I get is:
malloc: * mmap(size=629800960) failed (error code=12)
error: can't allocate region
** set a breakpoint in malloc_error_break to debug
The file I was using is about 250 MB large.
I know why it crashed on the main thread. My question is, why didn't it crash on a secondary thread?
I guess it can depend on the crash, but if it is a problem of lack of memory (you can both be using too much memory or be creating too many objects) it will crash the entire app.
You should try to test the app with smaller files and see how it behaves.
I'm trying to render a PDF page with some annotations on it (to email), and most of the time this works fine.
However, with this PDF in particular it seems to crash every time on the call to CGContextDrawPDFPage for the first page. I have added
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGContextSetRenderingIntent(context, kCGRenderingIntentDefault);
as a recommendation from CGContextDrawPDFPage taking up large amounts of memory but that did not seem to solve my issue.
I ran this through the profiler to see what was going on, and it slowly started allocating a bunch of memory until finally it hit 512MB of live bytes and died.
The strange thing is that when I render this to an image (for display on the device) context it seems to work fine but when I render it to a PDF context (for emailing with annotations), it breaks. All of the other PDFs I've tried work fine in both cases.
I was hoping that someone who's written a PDF viewer/annotator could test this out and see if this document works for them and if so, give me some tips about what they're doing to reduce the memory allocations of CGContextDrawPDFPage.
Another resource I looked at was this great SO Question.
Edit (more info on the crash):
90% of the time the crash doesn't actually show up, the gdb line displays but the app goes away and the stack trace doesn't show. (It says paused but there is no thread display). One time I saw it was an exc_bad_access and it showed this in the log:
malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Are you constructing the PDF on the main thread? If so, you may not receive the memory warning because you've blocked the signal while in execution, since the run loop never has a chance to dispatch the message to you.
Remove the exception breakpoint in xcode and it works fine.
I'm creating a video editing program with QTKit.
There is a sample program provided by apple here,
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/QTKitApplicationTutorial/CreatingaQTKitStoporStillMotionApplication/CreatingaQTKitStoporStillMotionApplication.html
My test program is based on this program, but use
QTMovie *movie = [[[QTMovie alloc] initToWritableFile:#"foo.mov" error:nil] autorelease];
and
[movie updateMovieFile];
for saving memories.
If there are not so many frames, the program runs well. But with so many frames, the program begins to show
QTKitServer(5618,0xa0924540) malloc: *** mmap(size=33554432) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
I checked memory leaks with Instruments,
but Live Bytes are not so big and found no memory leaks.
Overall Bytes is really big but is this a reason of this problem?
Any ideas will be appreciated.
Thanks,
The overall bytes should not be a problem unless there is an unreported memory leak.
After some googling some people seem to get this problem when compiling for 32bit, what architecture are you compiling against?