MonoTouch: the right way to handle ReceiveMemoryWarning

I have a MonoTouch app in the wild that sometimes dies with mprotect errno 12 (from memory) and it always seems to receive at least one ReceiveMemoryWarning in advance.

I am wondering how to properly respond to this. There are two types of things that my application can free: OpenGL textures and managed memory.

My questions about this:

  • OpenGL Texts: Will OpenGL Textures Remove?

  • Managed memory: I cannot free this directly, but I can get unnecessary references to it. This is enough?

  • GC.Collect: Should I call GC.Collect () at the end of my handler? Does GC.Collect collect anything right away or is it planning to build it for the future?

  • Anything else I can / should do in response to this?

+4
source share
1 answer

I stumbled upon this a while ago in my application using OpenGL. For me it was a memory leak.

[DllImport ("/System/Library/Frames/CoreGraphics.framework/CoreGraphics")] public static extern void CGDataProviderRelease (IntPtr provider);

and after calling GL.TexImage2D .....

you need to call CGDataProviderRelease (data.Handle);

now when you say you can look at this:

http://forums.monotouch.net/yaf_postst1541.aspx

+1
source

Source: https://habr.com/ru/post/1347570/


All Articles