On May 20, 2014, at 5:53 PM, vipgs99 <[email protected]> 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 protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to