[mono-android] Possible GC Bug?

Aaron Knabb aknabb at mobileepiphany.com
Fri Mar 18 17:24:51 EDT 2011


Thanks for your input Jon. So if I understand correctly, I should call
GC.Collect regularly? I don't see how to know what objects (assuming this
isn't exclusive to Bitmaps) are allocated in Dalvik and which ones aren't.
If that's the case, then I should call collect *just in case* there's
something that needs to be cleaned up.

-Aaron

On Fri, Mar 18, 2011 at 10:56 AM, Jonathan Pryor <jpryor at novell.com> wrote:

> On Mar 18, 2011, at 12:43 PM, Aaron Knabb wrote:
> > However, if I am creating and disposing of a large bitmap every time my
> activity is recreated (say in an ImageView), I run out of memory before
> long.
>
> The problem -- which is present on every GC system -- is that Mono's GC
> doesn't know how big the Dalvik-allocated bitmap is (just as .NET's GC
> doesn't know that you just called Marshal.AllocHGlobal() to allocate 4GB of
> memory...). Furthermore, Mono's GC _can't_ know how big the Dalvik-allocated
> bitmap is, and even if you knew how much memory it took
> GC.AddMemoryPressure() isn't supported.
>
> Thus, in this (and similar) cases you need to help the GC out, as you know
> things the GC doesn't, and thus the GC.Collect() call is appropriate.
>
>  - Jon
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110318/f7cf48d7/attachment.html 


More information about the Monodroid mailing list