Ah, Delphi apps and their bloated initializations strike again.  :-)

Assuming you're coding for an NT-based kernel, try this:

        procedure TrimWorkingSet;
        var
          MainHandle: THandle;
        begin
          MainHandle := OpenProcess(PROCESS_ALL_ACCESS, FALSE,
GetCurrentProcessID);
          SetProcessWorkingSetSize(MainHandle, $FFFFFFFF, $FFFFFFFF);
          CloseHandle(MainHandle);
        end;

I use this in several applications that are resident in memory but
rarely accessed.  One caveat:  once you do this, your application is
swapped out of RAM.  If it needs to perform quickly, then you don't want
to do this!

Alternatively, read the SDK docs on SetProcessWorkingSetSize and use it
to set the minimum and maximum working set to a fixed amount.  Just be
careful about setting it too large or you may prematurely get refusals
to allocate more memory.

----
Michael Bowers                                           Desktop
Solutions R&D
Sr. Applications Programmer Analyst         Memorial Hermann Healthcare
System
[EMAIL PROTECTED]
Phone:  713/448-6306                The more you tighten your grip,
Microsoft,
Pager:  713/605-8989 x21934         the more systems slip through your
fingers

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Jack
Sent: Wednesday, August 10, 2005 7:06 PM
To: [email protected]
Subject: Delphi Apps Memory usage

Hello all,

A Delphi application with only one form and nothing else takes 6MB
memory if it's compiled with Delphi 2005, or 3.6MB if compiled with
Delphi 5. That's very big for an application that does nothing.
However, if I minimize the window to task bar, the memory usage drops to
below 1MB. Then I activate the window again, the memory usage goes up to
1.xMB but does not go up all the way to 6MB or 3.6MB.
This works quite mysteriously.

A VB app that I use with skinned forms and does a lot of things takes
below 3MB memory. When it's minimized to tray icon, it takes 600KB.

So my question is, is there any way to reduce footprint in memory?
It feels strange that the real app in VB that needs the VB runtime
libraries takes less memory then an empty Delphi app.

--
Best regards,
Jack

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to