Disposing a Bitmap through its Finalizer

Posted by devoured elysium on Stack Overflow See other posts from Stack Overflow or by devoured elysium
Published on 2010-05-12T14:56:52Z Indexed on 2010/05/12 15:04 UTC
Read the original article Hit count: 179

Filed under:
|
|
|
|

I have a complex program in which I have to first create, then use wrappers around bitmaps and send them across a lot of different classes. The problem in the end is deciding which classes should dispose the bitmaps. Most of the time the end classes don't know if they can indeed dispose the bitmap as the same bitmap can be used in several places. Also, I can't just copy the bitmaps because this is a kind of resource intensive algorithm and doing it would be dead slow.

I looked up on reflector for Image/Bitmap's implementations and they seem to use the Dispose Pattern. So, even if I don't call Dispose(), the CLR will eventually call it some other time.

Is it too bad if I just let the bitmaps be as they are, and let the finalizer take care of them?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET