[Mono-list] Two questions about System.Windows.Controls.Image

Paolo Molaro lupus at ximian.com
Wed Aug 22 09:31:12 EDT 2007


On 08/17/07 Spencer, Matthew wrote:
>  Either I am using it incorrectly, or there is a severe memory leak in
> its implementation.  The way I am using it is to create two Image
> objects, and fade between the two of them, repeatedly loading the next
> image by calling SetSource(..) on the hidden object.  It appears that
> the memory of previous images is never released.  Is this what is
> expected, or is there a problem with the current implementation?

Please post a complete sample that can be used to reproduce the issue so
we can debug it.

> My next question is about garbage collection when the bulk of the
> storage for an object is in native space (as I think it is with the
> Image class).  I know I have done this before with Java and the garbage
> collector never kicked in because the runtime was only aware of a small
> amount of data being consumed by unreferenced objects (a reference to
> the native data store).  I'm not sure if Mono uses a similar policy on
> deciding if garbage collection is necessary, but this may cause a
> problem for Silverlight apps in the future if it does.

Version 2.0+ of the runtime supports the
GC.AddMemoryPressure()/RemoveMemoryPressure() for this purpouse: call
the first when allocating the unamanged data and the second when
releasing it. We currently do nothing with this, but it's good to have
the stuff in place for when the GC will make its decisions based also on
this.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better


More information about the Mono-list mailing list