Hi David,
  If you are working on any ot the NT based OSes (NT, Windows 2000, XP),
this is normal behaviour.  If your Delphi app has allocated and freed the
memory, and the delphi memory manager has done the appropriate stuff, then
you are llooking at the effects of the OS memory manager.

  Lots of folk say that the allocations reported by task manager tell lies.
This is partly true.  The task manager show the memory that is (sort-of)
allocated for a particular process, whether it is using it or not.  This
value always seems to grow and to never shrink.  It is usually indicative of
the maximum amount of memory that the process has ever allocated.

  There is an API function (SetWorkingProcessSize) which allows you to
programmatically shrink the virtual heap from within your program.  If you
specify -1 for both maximum and minimum values, the OS will re-think the
allocation for your process.  This is not a good thing to do frequently.
Essentially it swaps your app completely out to disk, and sets the memory
allocation to zero.  Moments later your app will swap back in from disk and
will chew up the amount of physical RAM that it truly needs.

  Having reduced your app's memory requirements to zero rerquires a lot of
work from the OS to re-build the true picture in RAM, and of course the
disk-swap is a very big performance hit.  Hence: don't use it a lot.

  If in the normal course of your app's life it allocates huge amounts of
RAM for a while, then frees it, then goes back to being not partucularly
greedy for quite a long time, you might be able to find a good strategic
place to pop in a call to SetWorkingProcessSize(Application.handle,-1,-1)
which should make things look better in the task manager, and might give the
OS a bit of a boost as well.

  Hope this helps, and that I haven't told too many lies.

Trevor

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of David O'Brien
> Sent: Wednesday, 15 January 2003 11:54
> To: Multiple recipients of list delphi
> Subject: [DUG]: Memory usage
>
>
> I have an app that reads files into a memory stream one at a time, checks
> them, then free's the memory stream after each file.
>
> In task manager, the memory raises to the size of the memory stream as
> expected, but when the memory stream is freed the memory used never drops
> back. Some of the files are upwards of 100Mb.
>
> Does this look like a problem or is it normal behaviour?
> Is there any way I can force the memory used back to the lower level?
>
> Cheers,
> Dave.



---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to