Disposing of brushes

  • Thread starter Thread starter Peter Webb
  • Start date Start date
Christopher Ireland said:
It is interesting that you should say that. I hadn't appreciated that there
was a finite set of GDI handles. Would you be so kind as to send me a link
to something I can read about this? It is very relevant to the area in which
I work.

http://msdn2.microsoft.com/en-us/library/ms724291(VS.85).aspx
has some detail. I'm afraid I don't know much about it really - just
that it's a potential issue.
Yes, I see. One scenario would be a defect in the finalizer code, and the
other would be a defect in the GC code that calls the finalizer.
Exactly.


I guess this is the greyest area for me. Say there was a defect in the GC,
either one of the two scenarios described above, in that the GC wasn't
releasing memory. From what I understand of what you've written, you seem to
be suggesting that even in this case it is the responsibility of the OS to
recuperate the memory once the application has closed.

Absolutely. The OS shouldn't allow a process which has been killed to
still take up memory.
This goes against what I've understood of memory allocation working in
environments which don't have managed memory capabilities. I believe I've
seen cases where applications use up a chunk of memory making it unavailable
to the OS; the memory use after running the application was greater than the
memory use before running the application. In these cases, therefore, it
seemed to me that the OS was not responsible and was even incapable of
recuperating such memory and it was the responsibility of the programmer of
the application to make sure such things didn't happen.

The OS is responsible for memory allocation to individual processes,
and for noticing when processes die etc - and releasing appropriate
resources. To take a non-memory example, if an application (managed or
otherwise) has a file open and locked, but then the application dies,
the file handle should be released by the OS, and the file unlocked.
Thank you for helping me deepen my understanding on this subject!

I'm just sorry I can't give more links about this.
 
Jon,
http://msdn2.microsoft.com/en-us/library/ms724291(VS.85).aspx
has some detail. I'm afraid I don't know much about it really - just
that it's a potential issue.

Thanks for the link, Jon! I didn't know that.
The OS is responsible for memory allocation to individual processes,
and for noticing when processes die etc - and releasing appropriate
resources. To take a non-memory example, if an application (managed or
otherwise) has a file open and locked, but then the application dies,
the file handle should be released by the OS, and the file unlocked.

I see. I had thought it was the responsibility of the programmer (in
non-managed memory environments) or the GC (in .NET) to make sure all memory
and resources used by the application were released before the application
closed. Glad to hear I can now blame the OS ;-)
I'm just sorry I can't give more links about this.

This is the problem. If more accurate information about this area was
available I'm pretty sure I wouldn't need to use up kind people's time, such
as yours, asking them to help me clarify it!

--
Thank you,

Christopher Ireland
http://shunyata-kharg.doesntexist.com

"The only good is knowledge and the only evil is ignorance."
Socrates
 

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