Reputation: 1189
I have a MonoTouch app out in the wild that dies sometimes with mprotect errno 12 (out of memory), and it always seems to get at least one ReceiveMemoryWarning notification beforehand.
I'm wondering what the right way to respond to this is. There are two types of things that my app could free: OpenGL textures and managed memory.
My questions about this are:
OpenGL textures: Will deleting OpenGL textures help?
Managed memory: I can't free this directly, but I can get null out references to it. Is that enough?
GC.Collect: Should I call GC.Collect() at the end of my handler? Does GC.Collect do anything immediately, or does it schedule a collection for the future?
Anything else I can/should do in response to this?
Upvotes: 4
Views: 658
Reputation: 31
I ran into this a while back in my app using OpenGL. For me, it really was a memory leak.
[DllImport("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")] public static extern void CGDataProviderRelease(IntPtr provider);
and after you call GL.TexImage2D.....
you need to call CGDataProviderRelease(data.Handle);
now that being said, you might want to look at this:
http://forums.monotouch.net/yaf_postst1541.aspx
Upvotes: 1