Re: Resource Leak



"jc" <jc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:78AE1A30-9259-4C79-A329-AA8749266852@xxxxxxxxxxxxxxxx
I noticed (using Task Manager), that once the dialog box
opens, the application memory usage increases from
3 MB to 30 MB, but when the dialog box is closed, the
memory usage does not decrease. Since, the dialog box
variable is declared locally, shouldn't the memory decrease,
because the dialog box variable is no longer in scope?

Is the application leaking?


Not necessarily. The Open File dialog is a Windows system dialog whose resources and code are in a Windows DLL. When you first show it, Windows loads this DLL and instantiates the dialog. But when the dialog is closed, Windows might not be aggressive about unmapping the DLL from your process, or even reclaiming the instance memory of the dialog (it might just mark it as unused and available for a subsequent allocation).

To make Windows aggressively reclaim as much memory as possible, call SetProcessWorkingSetSize((SIZE_T) –1, (SIZE_T) –1) as stated in http://msdn.microsoft.com/en-us/library/ms686234%28VS.85%29.aspx

I believe this is called for you if you minimize your window, so if you minimize the dialog, you can achieve the same thing without adding any code.

-- David

.



Relevant Pages

  • Re: Slow performance
    ... once the program opens up. ... memory is too low. ... Windows Live Once Care, and I usually notice improvement after I run the ... A visit to Event Viewer. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: The document name or path is not valid
    ... *check the file permissions for the document or drive. ... but we get it with using Windows Terminal Service ... When Word opens a document, ... If you don't properly shut down a memory stick using the control on the ...
    (microsoft.public.word.docmanagement)
  • Re: The document name or path is not valid
    ... even all the path and permission is check on the server ... When Word opens a document, ... If you don't properly shut down a memory stick using the control on the ... Windows taskbar, then Windows does not close all the files. ...
    (microsoft.public.word.docmanagement)
  • Re: Growing memory usage in D4 app with SerialNG
    ... it must run on a Windows platform, usually a laptop, and the hardware that might use the RTS and CTS has a limited amount of memory for a buffer, and it would certainly overrun if it were asked to hold off transmission for any longer than a hundred mSec or so. ... But while it was easy to have an almost-realtime program run on DOS, one will have all kind of problems when the same is attempted on Windows. ... The initial memory usage shown when I minimize the application is 1100 kB, which is exactly what I would expect for those figures, but I don't know why it should keep climbing. ...
    (comp.lang.pascal.delphi.misc)
  • RE: Virtual memory
    ... You can configure virtual memory in windows xp and thereby improve the ... How to set performance options in Windows XP ... if you have background programs such as printing or disk ... It is also known as the paging file. ...
    (microsoft.public.windowsxp.perform_maintain)