From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-04-22 14:44:37
shiwei xu wrote:
> Most of the C++ programmers do not benefit from "Garbage Collection"
> technique (GC). They are sick of deleting objects but have to do this.
> There are some C/C++ memory GC implementations, but they are complex
> and are not widely used.
> I am going to introduce a new memory management technique named "GC
> Allocator". "GC Allocator" isn't an implementation, but a concept.
> Now, we have two "GC Allocator" implementations, named "AutoFreeAlloc"
> and "ScopeAlloc".
> This article consists of three parts:
> 1. What is GC Allocator?
> 2. GC Allocator implementations: ScopeAlloc and AutoFreeAlloc
> 3. Applications based on GC Allocator
> For more information, see
> To obtain a copy of this paper in pdf format click
> from google
> code <http://code.google.com/p/stdext/downloads/list>).
If I understand correctly, your GC allocators delete all
allocated blocks when the allocator itself is destroyed,
or can be explicitly forced to free everything. Basically,
this works by imposing a hard upper bound on the lifetime
of a group of objects, rather than dealing with them separately.
I think that this is useful in some contexts. (Enough that I implemented
a simple version about a year ago). However, it is not
always applicable. Consider your List template. As I understand
it, if I have a List that exists for the duration of the program,
and I am often adding and removing elements, then the
memory for the elements will just build up until the List