0

I am developing an app on iPod touch, that uses the camera, displays a preview and takes pictures (all that through an AVCaptureSession). What I don't understand is that my app sometimes gets killed by launchd after a memory warning...although it uses no more than 2 MB in RAM (see attached screenshot). The console tells me

Aug 16 15:16:35 Wiggler[109] <Warning>: Received memory warning. Level=1
...
Aug 16 15:16:58 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.tMyCompany.Wiggler[0xd83d]) Exited: Killed: 9

On the other hand, I can successfully run other apps that use tons of RAM (more than 100 MB) without any crash nor memory warning.

What is wrong with my app ? What am I missing ? Is it a bug or a memory leak within the AVFoundation (the framwork that provides AVCaptureSessions) ? I can't see why my app is killed while it uses so little memory...

Thanks for your help.

instruments screenshot

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
Daladim
  • 198
  • 10
  • I really doubt about the app with 100 MB of live bytes. How about trying to release some memory in the didRecevieMemoryWarning method if all view controllers? – Praveen S Aug 16 '11 at 13:39
  • do you have leeks in your app? – Alex Terente Aug 16 '11 at 13:40
  • I don't think so. The app crashed a minute ago [without any detected leak](http://img29.imageshack.us/img29/60/memoryleaks.png). Instruments did find a couple of leaks some time before though, but it did non exceed 32 Bytes. – Daladim Aug 16 '11 at 14:50

2 Answers2

4

You almost surely are using more memory that what Allocations is showing you.

From your snapshot, it seems to me that you are not using the VM Tracker tool. Select the "snapshot automatically" option of the VM Tracker and then check both the "dirty" and "resident" size.

This will give you a more "global" view of your app memory usage. It will not help you to fix your allocation problems, if any, anyway, but at least it could explain why the memory warnings get in.

For an excellent explanation of what "dirty" and "resident" memory is, look at this from S.O.

Community
  • 1
  • 1
sergio
  • 68,819
  • 11
  • 102
  • 123
  • Hum... Here is [what I have](http://img163.imageshack.us/img163/5708/instruments2.png) when running VM tracker tool. Yet I don't completely understand it. What exactly is the dirty memory ? I read somewhere that it is memory out of my reach, and that should be disposed by the garbage collector, but this explanation sounds weird... Why the GC would keep so much dirty memory ? Any clarifications about this would be greatly appreciated ! Thanks :) – Daladim Aug 16 '11 at 14:43
  • Thanks for your edit. That is what I read one hour ago. But what I don't get is : does this dirty memory cause the memory warning ? If so, what could I do (since it is looked at by the GC, it should be responsible for its deletion, shouldn't it ?) – Daladim Aug 16 '11 at 14:53
0

Try configuring your AVCaptureSession for smaller captures and see what effect that has on dirty memory use. The GC can't collect memory that is in use (as part of the capture or preview, etc.)

hotpaw2
  • 70,107
  • 14
  • 90
  • 153