Re: how to mumap memory from CoreGraphics?
Re: how to mumap memory from CoreGraphics?
- Subject: Re: how to mumap memory from CoreGraphics?
- From: David Duncan <email@hidden>
- Date: Tue, 20 May 2014 18:21:27 -0700
On May 20, 2014, at 5:53 PM, vipgs99 <email@hidden> wrote:
> I have an app that used a lot CoreGraphics and by using "UIGraphicsGetCurrentContext()" and "CGContextDrawImage" and etc CoreGraphics founctions, these functions call mmap() and these use a lot virtual memory.
> The problem is when I receive low memory warning, the memory used by mmap() in virtual memory will not release automaticly, and I don't have a way to manually release them. The app crash due to the virtual memory pressure, my real RAM usage is very low. How can I manually release the mmap() memory created by CoreGraphics? Thx
Virtual memory will not crash you unless you reach the VM limit of 2GB. If you’ve reached that with only virtual memory then you crash due to something else trying to allocate memory and not being able to.
Typically if you are drawing content however, you won’t be limited by the VM limit, but by available memory. The way to resolve that is to release the objects (images, context, etc) that you are holding on to. If you are calling UIGraphicsGetImageFromCurrentContext(), then you need to release those images (and ensure that any image views displaying them have their image set to nil). If this is the result of view drawing (via -drawRect: typically) then you need to release the views themselves. However it is atypical to have views consume that much memory, unless your views implementing -drawRect: are especially large, or especially numerous.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden