[mono-android] SPAM-LOW: Re: GridView not releasing view objects
HSSoftware
david at headstandsoftware.com
Mon Jan 30 15:09:26 UTC 2012
Jonathan,
I wondered if M4A 4.0.3 has any of the GC fixes that you mentioned, that are
highlighted in red below?
Thanks,
David Bakkom
From: Jonathan Pryor-2 [via Mono for Android]
[mailto:ml-node+s1047100n5081548h86 at n5.nabble.com]
Sent: Friday, December 16, 2011 3:47 PM
To: HSSoftware
Subject: SPAM-LOW: Re: GridView not releasing view objects
On Dec 16, 2011, at 9:43 AM, HSSoftware wrote:
> Attached is a reproducible case.
Thank you, that simplified investigations. :-)
> Is there something stupid I am doing, or is GC on a holiday?
The GC is on holiday. :-)
Well, not exactly. The problem here is that the GC has a limited view of
memory -- it only knows about the memory it's allocated. In the interest of
being performant, it doesn't want to perform collections that often, as
collections are slow. So collections are only performed when the GC thinks
it's allocated "enough" memory (subject to configuration, etc.).
The problem here is that Mono's GC doesn't know about memory allocated by
the Android GC, and thus Mono's GC doesn't know that a _ton_ of memory is
being kept alive by Mono; all Mono's GC sees is a lot of (comparatively
small) instances running around. Consider that for most managed objects, the
only instance data is a couple of IntPtrs (to hold the JNI handle value) --
sgen thinks your Bitmap instance is only ~28 bytes in size, so you can
allocate LOTS of those before triggering a collection...
The short-term fix is to help the GC out, by overriding
ImageGridActivity.OnDestroy() and invoking GC.Collect():
protected override void OnDestroy ()
{
base.OnDestroy ();
GC.Collect ();
}
Once I do that, your test app stabilizes at ~255 global references on my
Xoom.
The longer-term fix involves us adding GC.AddMemoryPressure() and
GC.RemoveMemoryPressure() support and some "glue" logic so that sgen "knows"
how big the Java-side bitmap actually is, and use that to modify how often
collections are performed. There's no ETA on this.
- Jon
_______________________________________________
Monodroid mailing list
[hidden email]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
_____
If you reply to this email, your message will be added to the discussion
below:
http://mono-for-android.1047100.n5.nabble.com/GridView-not-releasing-view-ob
jects-tp5078401p5081548.html
To unsubscribe from GridView not releasing view objects, click here
<http://mono-for-android.1047100.n5.nabble.com/template/NamlServlet.jtp?macr
o=unsubscribe_by_code&node=5078401&code=ZGF2aWRAaGVhZHN0YW5kc29mdHdhcmUuY29t
fDUwNzg0MDF8MTU5NTQwMjIwMA==> .
<http://mono-for-android.1047100.n5.nabble.com/template/NamlServlet.jtp?macr
o=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namesp
aces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web
.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.n
aml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail
.naml> NAML
--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/RE-SPAM-LOW-Re-GridView-not-releasing-view-objects-tp5441678p5441678.html
Sent from the Mono for Android mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120130/286a86a8/attachment.html>
More information about the Monodroid
mailing list