Objects and Datatypes that needs to be disposed explicitly

G

Guest

Hi,
Till now i thought that any object or datatypes used in a dot net
application are disposed and memory is freed automatically once they go out
of scope.

But when i saw my application memory usage in the Remote Performance Monitor
i realized that it is not the case. Some of the bitmaps that i have created
are not getting disposed even when they go out of scope.

Can some one tell me what are the objects and datatypes that needs to be
disposed explictly for the GC to collect them.

Thanks,
Murthy
 
G

Guest

Murthy,
Most graphics objects require you to manually dispose of them. Examples
include Bitmaps, Brushes, Pens. Also, you need to ensure that you dispose of
all forms. If you do not call the Form.Dispose method, the form will not be
marked for disposal and will live for the lifetime of the application.

Rick D.
Contractor
 
G

Guest

You may have an incorrect notion of what "Disposed" is. Just because an
object goes out of scope doesn't mean the memory it was using gets freed -
not from the GC heap or from physical memory. Its root simply gets
destroyed. It will get collected when the next GC occurs (well maybe the
one after that if it's got a Finalizer).

This Webcast might be useful:

http://msevents.microsoft.com/cui/eventdetail.aspx?eventID=1032318790&Culture=en-US


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
M

Magnus Bergh

If you do not call the Form.Dispose method, the form will not be
marked for disposal and will live for the lifetime of the application.

Does that apply to non-modal forms as well?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top