6

My app has a thread that does some time consuming job for more than a minute and the app consumes around 6.8MB of memory. I receive a memory warning after sometime and then it gets killed. There is nothing that I can release, and I am using not even 7MB of memory...driving me crazy...any advice please?

Abix
  • 260
  • 2
  • 16
  • Use a debugger or memory leak tool. http://stackoverflow.com/questions/172125/avoiding-finding-and-removing-memory-leaks-in-cocoa – Matt Ball May 20 '10 at 16:55
  • Also, make sure you are testing on the device and not just the simulator. – rickharrison May 20 '10 at 17:29
  • I am running it on the device; on simulator i do not get memory warning unless i simulate it. When the app dies, gdb says this... Program terminated with signal 0, Signal 0. So, it is the OS who is killing my app. It is only taking 7MB of memory and still the OS is killing it!!! Restarting the device does not help either, may be I am missing something? "Leak" shows no leak and constant usage of 6.8MB of memory. – Abix May 20 '10 at 18:19

2 Answers2

2

Maybe your memory is super-fragmented? Even 7mb full of leaked data shouldn't kill your app. You ought to have at least 20mb to play with. Try rebooting the phone and see if that helps.

Dan Ray
  • 21,623
  • 6
  • 63
  • 87
1

I still do not know why it is happening, but now I have a found a workaround. Instead of running this job in a thread, if I run it on the main thread, neither I receive memory warning not it gets killed. But then I cannot show the progress in the UI. I am going to use NSTimer to do it.

Abix
  • 260
  • 2
  • 16