Board index » delphi » ** Help ** - Keeping track of Heap Space Avail in Delphi II

** Help ** - Keeping track of Heap Space Avail in Delphi II

I have asked this before but I didn't get an answer so come on all you
so-called gurus answer me this !

Q. How can I keep track of heap space used in Delphi 2.0. I want to
check that the garbage disposal is working correctly ie as I open and
close dialogs the heap space available should always come back to the
same value.

For Delphi 1.0 I used the MemAvail function, but this isn't available in
Delphi 2.0

Let's get those brains working :)

Thanks
--
Moebius

 

Re:** Help ** - Keeping track of Heap Space Avail in Delphi II


On Tue, 8 Oct 1996 13:00:38 +0100, Moebius <R...@mtechsec.demon.co.uk>
wrote:

Quote
>Q. How can I keep track of heap space used in Delphi 2.0. I want to
>check that the garbage disposal is working correctly ie as I open and
>close dialogs the heap space available should always come back to the
>same value.

Look in the online help under "memory-management routines".
--
Ray Lischner, Tempest Software, Inc., Corvallis, Oregon, USA
Author of Secrets of Delphi 2 (http://www.tempest-sw.com/secrets/)

Re:** Help ** - Keeping track of Heap Space Avail in Delphi II


On Tue, 8 Oct 1996 13:00:38 +0100,

Quote
Moebius  <R...@mtechsec.demon.co.uk> wrote:
>I have asked this before but I didn't get an answer so come on all you
>so-called gurus answer me this !

>Q. How can I keep track of heap space used in Delphi 2.0. I want to
>check that the garbage disposal is working correctly ie as I open and
>close dialogs the heap space available should always come back to the
>same value.

I suspect this may not be an easy question.  I've posted a similar one also
and have not gotten any reply.  Meanwhile I use
GetHeapStatus().TotalALoocated and TotalFree to give me an idea if memory
is properly returned.  I suspect though that this may not be completely
accurate, but this is the best I know so far, without having to install
commercial software. Please let me know if you find out anything new or
different.

Lito

Lito Dizon
adi...@us.net

Re:** Help ** - Keeping track of Heap Space Avail in Delphi II


In article <23498.adi...@mail.us.net>, Angelito Dizon
<adi...@mail.us.net> writes

Quote
>Please let me know if you find out anything new or
>different.

>Lito

I have used HeapStatus.TotalFree to display the free memory on the
statusbar of my MDI application. What I have observed is that even
opening a simple dialog like an 'About' window seems to leak memory (ie
the value doesn't return to the initial value before I opened the dialog
*for the first time*).

ie Boot Application   - TotalFree 21912
   Open About window
   Close About window - TotalFree 21888
   Repeat action      - TotalFree 21888 thereafter

What happened to the 24 missing bytes?

The about-window code could not be simpler ie

  procedure TMainForm.HelpAboutItemClick(Sender: TObject);
  begin
    AboutBox.ShowModal;
  end;

You should see what happens when I open a child window, it's like a
cardboard suitcase in the rain, though that could just be down to shoddy
programming!!

I'm have observed a similar results in Delphi 1.0, any ideas ?

--
Moebius

Re:** Help ** - Keeping track of Heap Space Avail in Delphi II


Date :02:28:41 PM Wed 13 Nov 1996 GMT

I don't think its a leak, cos it only happened the first time you showed
the window.
Try destroywnd'ing the window and see if you get your memory back.  Or, if
you can't do that, check heap before the window is created and then after
it is free'd.

--
Sam Liddicott                   |   Nothing I say is to be attributed as |
Campbell Scientific Ltd.        | a company statement or representation. |
Campbell Park, 80 Hathern Road, *----------------------------------------+
Shepshed, Leic. United Kingdom. LE12 9AL        Phone: +44 (0) 1509 601141
Email: s...@campbellsci.co.uk                    Fax:   +44 (0) 1509 601091

Moebius <R...@mtechsec.demon.co.uk> wrote in article
<b43YNAAHjLXyE...@mtechsec.demon.co.uk>...

Quote
> In article <23498.adi...@mail.us.net>, Angelito Dizon
> <adi...@mail.us.net> writes

> >Please let me know if you find out anything new or
> >different.

> >Lito

> I have used HeapStatus.TotalFree to display the free memory on the
> statusbar of my MDI application. What I have observed is that even
> opening a simple dialog like an 'About' window seems to leak memory (ie
> the value doesn't return to the initial value before I opened the dialog
> *for the first time*).

> ie Boot Application   - TotalFree 21912
>    Open About window
>    Close About window - TotalFree 21888
>    Repeat action      - TotalFree 21888 thereafter

> What happened to the 24 missing bytes?

> The about-window code could not be simpler ie

>   procedure TMainForm.HelpAboutItemClick(Sender: TObject);
>   begin
>     AboutBox.ShowModal;
>   end;

> You should see what happens when I open a child window, it's like a
> cardboard suitcase in the rain, though that could just be down to shoddy
> programming!!

> I'm have observed a similar results in Delphi 1.0, any ideas ?

> --
> Moebius

Re:** Help ** - Keeping track of Heap Space Avail in Delphi II


You might try to not have the aboutwindow at all. You can do so with
the project options.
As soon as you need to show it do this:
        TAboutForm.Create(Application).ShowModal;
In the window itself you need to set the OnClose event, in this method
you want the following line:
        Action := caFree;

Now try again and see your heap...

L8r, MW.

Quote
>> I have used HeapStatus.TotalFree to display the free memory on the
>> statusbar of my MDI application. What I have observed is that even
>> opening a simple dialog like an 'About' window seems to leak memory (ie
>> the value doesn't return to the initial value before I opened the dialog
>> *for the first time*).

>> ie Boot Application   - TotalFree 21912
>>    Open About window
>>    Close About window - TotalFree 21888
>>    Repeat action      - TotalFree 21888 thereafter

>> What happened to the 24 missing bytes?

>> The about-window code could not be simpler ie

>>   procedure TMainForm.HelpAboutItemClick(Sender: TObject);
>>   begin
>>     AboutBox.ShowModal;
>>   end;

>> You should see what happens when I open a child window, it's like a
>> cardboard suitcase in the rain, though that could just be down to shoddy
>> programming!!

>> I'm have observed a similar results in Delphi 1.0, any ideas ?

>> --
>> Moebius

L8r. MW.

Other Threads