How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

Standish P stndshp at gmail.com
Tue Aug 17 13:10:57 EDT 2010


On Aug 16, 4:20 am, Malcolm McLean <malcolm.mcle... at btinternet.com>
wrote:
> On Aug 16, 10:20 am, Standish P <stnd... at gmail.com> wrote:> [Q] How far can stack [LIFO] solve do automatic garbage collection and
> > prevent memory leak ?
>
> Most programs can be written so that most of their memory allocations
> are matched by destructors at the same level.
>
> However the allocations that can't be written this way typically tend
> to be the small frequently-called ones used for nodes in dynamic graph
> objects, or small resizeable buffers to hold strings and the like.
> This is where you get the performance hit with repeated calls to
> malloc() and free().
>
> So generally it's not worthwhile writing a stack allocator for a
> normal program. That's not to say there aren't a few individual cases
> where it can help performance. (See the chapter "Memory games" in my
> book Basic Agorithms for details about memory allocation strategies).

all the page numbers in your books TOC have a little varying offset
from actual, pictures are nice for kids ..



More information about the Python-list mailing list