BS> Maybe somebody can clear up my confusion. I somehow got the impression
that
> in Delphi/Windows, unlike TP/DOS, any memory allocated dynamically with
> GetMem() or New() is not automatically returned to the system when the
> program exits. In other words, in Delphi, you have to free it yourself
with
> FreeMem/Dispose.
BS> A program I wrote recently builds a large tree structure with Getmem's
nd
> New's. I had not completed the shutdown code to walk the tree and
elease
> the memory, when the customer demanded to see what the program looked
like.
> Wanting to warn him of the potential loss of Windows resources, I put in
> ShowMessage to list the MemAvail before and after the tree was built.
BS> My expectation was that each time the program was run within one windows
> session, the MemAvail would progressively decrease. Surprise, I got
> essentially the same numbers every time I ran the program.
BS> Can somebody please explain what I have mis-understood ?
Windows released the memory when you shut the application down.
Unlike DOS, you are not working in a processor-controlled memory
space, it's a Windows-controlled memory space.
You would only need to be concerned if you were using real mode
memory extensions such as EMS or XMS. But since you cannot use
such real mode structures from inside Windows, nothing to worry
about.
But don't be tempted to forget about garbage collection on shut
down...it's still good practice to clean up after yourself...
L.A.
-- SPEED 2.00 #2720: Finally picking up on subtleties huh?
--- Platinum Xpress/Win/Wildcat5! v2.0GU
---------------
* Origin: Grey Matter : (206) 526-2400 (1:343/210)
|