Re: Deallocating memory of a Bitmap created with a pointer to image bits
- From: "Bob Powell [MVP]" <bob@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Jun 2007 11:43:51 +0200
Obviously, if you've passed the image to picture boxes and other controls you cannot delete it until you've tidied up those references. Otherwise you'll get a null reference exception.
The rule is that you manage whatever you create and leave everything elsa alone for the objects that are responsible for them.
--
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
<anpasq@xxxxxxxxx> wrote in message news:1182154305.247992.89130@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Your so simple answers does not resolve the problem because the bitmap
is referenced by other
objects (PictureBox and others) so to manually call dispose I should
write code to keep
track of all the references around....
A clean solution should be to derive from the Bitmap class and
override the dispose method..
but as u know it is a sealed class..
so any other ideas ?
On 16 Giu, 14:08, "Bob Powell [MVP]" <b...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
You should call Dispose yourself when you've finished using the bitmap.
--
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consultinghttp://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Trickshttp://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQhttp://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
<anp...@xxxxxxxxx> wrote in message
news:1181927989.663758.214860@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> As described in the article KB814675
>http://support.microsoft.com/?scid=kb%3Ben-us%3B814675&x=9&y=17
> "When a Bitmap object is created with a pointer to image bits, the new
> object may or may not use the memory at that address as backing for
> the image. Therefore, the application must make sure that the memory
> can be used during the life of the Bitmap object"
> That's ok but ..
> As I know there is no way to know when the Bitmap object will be
> disposed.
> so when should the supplied memory deallocated ?
> Any Idea ?
.
- Follow-Ups:
- References:
- Prev by Date: Re: Deallocating memory of a Bitmap created with a pointer to image bits
- Next by Date: Re: Deallocating memory of a Bitmap created with a pointer to image bits
- Previous by thread: Re: Deallocating memory of a Bitmap created with a pointer to image bits
- Next by thread: Re: Deallocating memory of a Bitmap created with a pointer to image bits
- Index(es):
Relevant Pages
|