Garbage collection

  • Thread starter Thread starter Veerle
  • Start date Start date
V

Veerle

Suppose you have a self-written control A that contains some other
controls. Some of these controls are .NET controls, others are COM
controls.

When clicking a button in a form, control A is created at runtime and
added to the controls collection of the form. Later on when clicking
another button in this form control A is removed from the controls
collection of the form, its dispose method is called and it is set to
nothing.

But when I look at the memory usage before adding the control to the
form and after removing it, there is big difference, like some part of
control A is still in memory somewhere???

If you call the dispose method on a self-written control (in the
previous example control A), can I be sure that the controls on this
control are properly disposed as well? Even if these controls are COM
controls?

Any suggestions on how I can track down the problem?
 
Cor said:
Veerle,

With a self written control that uses non managed code you have to take care
of your own disposing routines. You can find that under Idisposable.

http://msdn.microsoft.com/library/d...ref/html/frlrfsystemidisposableclasstopic.asp

However, the GC is not working directly. It is waiting if it is necessary to
start or that there is time to start.

Cor

Also, it depends on how you are checking the memory. If you
are using taskmanager or a similar tool, be aware that the
process working set will not be trimmed automatically.

Search the google newsgroup archive for "process working
set" for more information.
 

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

Back
Top