On Apr 12, 2012, at 8:02 PM, King Coffee wrote:
> I'm using the following code to allocate an image file to a ImageView 
> control, with instance name: image.
> 
> Bitmap bitmap = BitmapFactory.DecodeFile(matches[0]);
> image.SetImageBitmap(bitmap);

If you're not using `bitmap` after this point, you should be able to dispose of 
it:

        bitmap.Dispose();

> I tried to dispose of the control's context as follows:
> image.Context.dipose(), image.CacheDir.dispose().

It shouldn't be necessary to dispose of these members; no wrappers are 
generated unless you access the member. (That is, if you never use 
image.CacheDir, then you don't need to dispose of it as it will never have been 
wrapped.)

What might be useful is enabling gref logging to see how many Bitmap instances 
you're creating and if they're ever being freed:

        
http://docs.xamarin.com/android/advanced_topics/diagnostics#Global_Reference_Messages

        adb shell setprop debug.mono.log gref

 - Jon

_______________________________________________
Monodroid mailing list
[email protected]

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

Reply via email to