hi craig,
It seems to me, the garbage collector does not run as frequently in
mono4android as it does in .net, where it is potentially running a
firstgen collection every time you allocate objects. Mono4android
garbage-collects very lazy, only when the heap grows beyond certain
limits. Anyone with deeper knowledge about the GC may correct me here.
If your heap always grows and finally OOM-exceptions are thrown you
definitely have a leak (some objects are still referenced somehow).

I have not experenced leaks with textview, but here are some other insights.
In android it is very easy to leak memory. for instance, I had a very
hard to find leak with bitmaps and found that not only you need to call
Recycle on a dynamically loaded bitmap but also you need to set the
callback of the BitmapDrawable to null. I eventually ended up going
through my views on Activity.Destroy and set all Drawable.Callback to
null (i.e. Background of widgets etc.), recycle all dynamically loaded
bitmaps and unlink all views from their parents just to make sure.

Also I came across several bugs in android (for instance the gallery
widget does not recylce views) and many other problems, so don't expect
the android framework to be super bugfree.

Be careful with callbacks/eventhandlers in general and make sure you
destroy everything (break all possible links between objects, set
everything to null, unlink every child widget from its parent, etc.) so
that if there happens to be a leak, it does not hold a bunch of other
objects.

hth,
-- henon

On 31.07.2012 19:21, craig wrote:
> Honestly I'm still learning and didn't think of ListView until it was
> suggested by you and John.  I am going to eventually change my code to use a
> ListView because I think that's probably the cleaner way to code it now that
> you have pointed it out to me.
>
> But I don't necessarily want to just dismiss this thread if the issue goes
> away when I change to use ListView.  It seems that there is some fundamental
> issue with garbage collection or else some fundamental knowledge that I am
> lacking.  I just want to know why it is behaving as it is so I can better
> understand how Mono for Android GC works.  I've read the articles about Mono
> for Android GC on the support site but it didn't really help me to
> understand what is happening here.  Thanks.
>
>
>
>
>
> --
> View this message in context: 
> http://mono-for-android.1047100.n5.nabble.com/How-to-handle-garbage-collection-memory-leak-tp5711079p5711090.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to