Article View: borland.public.cppbuilder.nativeapi
Article #13456Re: SetProcessWorkingSetSize
From: Peter Below (TeamB)
Date: Mon, 13 Oct 2003 18:13
Date: Mon, 13 Oct 2003 18:13
45 lines
3067 bytes
3067 bytes
In article <3f8ac433@newsgroups.borland.com>, Chris Buys wrote: > 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. Why do you expect that to fix your problem? If you reduce the working set size your app will only bang into the wall earlier. You need to find and fix the source of the problem, not doctor the symptoms! > > I've already checked the DLL's code for any possible memory leaks, but could > not determine any. Any ideas? Memory fragmentation. You can get that easily by unsmart operations on large dynamic arrays or strings which you grow very often by small increments. The fix for that is easy: allocate a large array or string (if you can make a solid guess of the total memory needed make it at least that size) up front and work with this in a way that does not cause a reallocation of the memory block until you are done and know the exact size needed. If you cannot make a good guess of the memory needed start with a larger block and grow it by larger increments, e.g. 50% of the current size, when you run into the end. -- Peter Below (TeamB) Use the newsgroup archives : http://www.mers.com/searchsite.html http://www.tamaracka.com/search.htm http://groups.google.com http://www.prolix.be
Technical Details
Message-ID:
<VA.0000a535.0033d7a9@nomail.please>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f8ac433@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,656eae8ed23df311 X-Google-Attributes: gid10cc67,public X-Google-Thread: f94dd,656eae8ed23df311 X-Google-Attributes: gidf94dd,public X-Google-ArrivalTime: 2003-10-13 11:10:46 PST Date: Mon, 13 Oct 2003 20:13:55 +0200 Newsgroups: borland.public.cppbuilder.nativeapi,borland.public.delphi.nativeapi Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: Virtual Access by Atlantic Coast PLC, http://www.atlantic-coast.com/va Organization: TeamB Message-ID: <VA.0000a535.0033d7a9@nomail.please> Subject: Re: SetProcessWorkingSetSize From: "Peter Below (TeamB)" <100113.1101@compuXXserve.com> Reply-To: 100113.1101@compuXXserve.com References: <3f8ac433@newsgroups.borland.com> NNTP-Posting-Host: 62.226.186.94 X-Trace: newsgroups.borland.com 1066068450 62.226.186.94 (13 Oct 2003 11:07:30 -0700) Lines: 47 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail