Re: memory leak
- From: "Hilton" <nospam@xxxxxxxxxx>
- Date: Sun, 13 Aug 2006 20:55:24 GMT
Chris,
This has come up before, so no use beating a dead horse (I'm the guilty one
here since I first mentioned it), but here are some points which hopefully
helps to explain my comments:
1. If ALL objects were required to be disposed, would that be a design bug?
Of course it would, it is .NET with a garbage collector.
2. Then why do we have to dispose Bitmap? Because MS took a short-cut.
Note that MS have already said that they will *fix* this problem.
3. Another bad choice IMHO was to put Bitmap in System.Drawing - that is
the wrong place since you don't only draw with Bitmap and a Bitmap image
should not be directly associated with UI. It should be in System.Image or
something similar. Here is an example in pseudo-C#: Imagine you wanted to
convert all BMP files to PNG files using a command line EXE. It should
simply be "using System.Image; foreach BMPFile in directory { new Bitmap
(BMPFile).SaveAs (PNG); }" but instead we have to include System.Drawing
(UI stuff), plus we need to do our own memory management (the code above
would have a huge memory leak).
4. FWIW: I think Dispose should be an optional call, not a mandatory call
required to prevent a memory leak.
5. There are other things like why they called it SortedList instead of
SortedMap etc... (unrelated to Bitmap)
Bottom line, I love C#, work with it day in and day out, absolutely darn
amazing on Pocket PCs etc, so don't think for a second I'm bashing the C#
language, the .NET team, or Microsoft. Just sometimes, bad design decisions
get made (*IHMO*).
Hilton
"<ctacke/>" <ctacke[@]opennetcf[dot]com> wrote in message
news:eWyovzwvGHA.3372@xxxxxxxxxxxxxxxxxxxxxxx
The same has to be done on the full framework, and again, it's not a bug.
-Chris
"Hilton" <nospam@xxxxxxxxxx> wrote in message
news:gvJDg.12218$gY6.3863@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I bet you're doing something like "xyz.Image = new Bitmap (...)" - right?
If so, there is a bug in the CF design/implementation (IMHO) that forces
you to do your own memory management; i.e. for every "new Bitmap ()" you
do, you'll need to do a "Dispose()" on that bitmap when you're done with
it (aka malloc and free).
Let us know if that helps,
Hilton
"raju" <ponnurajs@xxxxxxxxx> wrote in message
news:1155390117.643466.283160@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hai
In my device application (windows ce application using vb.net), i
am having nearly 25 forms. Moving from one form to another form, just i
am hide the first form and show the second form.
Each form I am having some picturebox, putting images for that
picturebox using imagelist.
My application works very well. But, if the application running
contineously for 1 or 2 hours, i am getting error such as "low memory".
when i checked the memory, it will automatically increasing when
the application is in running. First initial time, it occupies 22 mb
and it increasing upto 32 to 35 mb.
What is the reason for this? and how to correct this memory
problem.
Regards
Raju.
.
- Follow-Ups:
- Re: memory leak
- From: <ctacke/>
- Re: memory leak
- References:
- memory leak
- From: raju
- Re: memory leak
- From: Hilton
- Re: memory leak
- From: <ctacke/>
- memory leak
- Prev by Date: Re: lnk file
- Next by Date: Re: memory leak
- Previous by thread: Re: memory leak
- Next by thread: Re: memory leak
- Index(es):
Relevant Pages
|