Re: Rules to avoid memory leaks?

From: Allen Bauer (abauer_at_spicedham.borland.com)
Date: 10/20/04


Date: Wed, 20 Oct 2004 09:28:17 -0700


> Strings are "managed" but even a reference counter has to be updated.
> TObject.Destroy or the "end" of a block does it. But it didn't happen
> for the main block or the finalization block of a unit. I'm pretty
> sure to have read that it caused some RTL leaks, at least in older
> versions. Maybe it's been corrected?

"Managed" types, such as strings, dynamic arrays, variants and interfaces
should be freed automatically when the finalization is called (even if there
is no explicit finalization declared). This is only important for
dynamically loaded packages or dlls. For stand-alone exes, since the
finalization is called during process shutdown and Windows already takes
care of freeing *all* process memory, this actually isn't strictly
nessesary.

-- 
Allen Bauer
Delphi/C#Builder Principal Architect
Borland Software Corporation.
http://blogs.borland.com/abauer