SetProcessWorkingSetSize
From: Chris Buys (chris_at_h-a-s.co.za)
Date: 10/13/03
- Next message: Martin James: "Re: Mutilthread App fail in HT Intel CPU?"
- Previous message: Serguei: "Re: Sharing a folder"
- Next in thread: Peter Below (TeamB): "Re: SetProcessWorkingSetSize"
- Reply: Peter Below (TeamB): "Re: SetProcessWorkingSetSize"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 13 Oct 2003 17:22:20 +0200
Hi everybody!
I'm having difficulties with setting the working set size of a process.
Here is the scenario:
A normal application loads a DLL dynamically and one of the calling
arguments
is the application's handle: Application->Handle (the app was written in
BCB5).
This goes fine over into the Delphi 5 DLL. ShowMessage-ing shows the same
number
inside the DLL.
Unfortunately the work the DLL does eats up memory like there's no tomorrow.
In the Win2000 TaskManager the memory usage for that process keeps going up
and after 30 min to 1 hour Win2000 runs out of page memory and throws an
error.
So I want to keep the working set of the memory down to sane levels with the
SetProcessWorkingSetSize API call.
Here is my code for the above action:
//--------------------------------------------------------------------------
----
procedure SetMemoryData(P : HWND; ceiling : Cardinal);
var
min, max, error : Cardinal;
begin
try
GetProcessWorkingSetSize(P,min,max);
if (Trunc((min + max) / 2) > ceiling) then
begin
if (SetProcessWorkingSetSize(P,1048576,2097152) = false) then
begin
error := GetLastError;
ShowMessage('error on setting size');
ShowMessage(IntToStr(error));
end;
end;
except on e:Exception do
ShowMessage(e.Message+' GetMemoryData');
end;
end;
//--------------------------------------------------------------------------
----
When the variables "min" and "max" are inspected after the Get-procedure,
their
values are zero (0). Just before the function is called the first time a
Get is done as
well and it returns non-zero data. Why? The same Handle (P) is used in
each instance!
I've already checked the DLL's code for any possible memory leaks, but could
not determine any. Any ideas?
Thank you in advance.
Chris
--------------------------------------
Chris Buys
Development
HAS Software (Pty) Ltd
- Next message: Martin James: "Re: Mutilthread App fail in HT Intel CPU?"
- Previous message: Serguei: "Re: Sharing a folder"
- Next in thread: Peter Below (TeamB): "Re: SetProcessWorkingSetSize"
- Reply: Peter Below (TeamB): "Re: SetProcessWorkingSetSize"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|