|
|
Up |
  |
Author: xushiweixushiwei Date: Apr 21, 2008 10:20
To obtain a copy of this paper in pdf format click here (http://
xushiwei.com/local--files/gc-allocator/GCAllocator.pdf or from google
code: http://code.google.com/p/stdext/downloads/list). Another copy is
also available on google docs ( http://docs.google.com/View?
docid=dds5zgx6_353dc5k4fcq) in html format.
Introduction
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
What is GC Allocator?
|
| Show full article (17.31Kb) |
|
| | 40 Comments |
|
  |
Author: Chris ThomassonChris Thomasson Date: Apr 21, 2008 13:40
[...]
AFAICT, your implementation is not thread-safe. For instance, I could not
use it to implement a producer/consumer pattern. Thread A allocates blocks
and passes them to thread B which frees them. Am I missing something?
|
| |
|
| | no comments |
|
  |
|
|
  |
|
|
  |
Author: marlow.andrewmarlow.andrew Date: Apr 21, 2008 18:50
On 21 Apr, 19:13, xushiwei gmail.com> wrote:
I took a quick look with particular interest
in what you have to say about scoped allocators.
It seems to me that there is some overlap with
what you are doing and the work by Pablo Halpern in
his N2523 submission to WG21 entitled "The Scoped Allocator
Model". See
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2523.pdf
IMO Pablo's proposal is more thought through.
I recommend you take a look.
[ huge prose snipped ]
The prose snipped seems to be a copy of the PDF article.
I am suprised the moderator did not comment on this.
It makes your post very long.
> When you creating a GC Allocator, You can use STD_NEW, STD_NEW_ARRAY
> to new objects.
> Frankly speaking, I don't like STD_NEW and STD_NEW_ARRAY.
|
| Show full article (1.32Kb) |
| no comments |
|
  |
Author: Lance DiduckLance Diduck Date: Apr 21, 2008 18:50
On Apr 21, 2:13 pm, xushiwei gmail.com> wrote:
Very Nice presentation!!
There aren't any real earth shaking new ideas here, but a good
overview of why choosing the best allocator for the job makes a huge
difference.
I have long been a fan of non-static allocator instances, and they do
make a huge difference esp in MT programs. There has been some recent
work with stateful allocators in the standard, but most of this work
was geared to changing the semantics of "regular type" rather than
improving allocator support in the library. (the idea is that each
allocator instance is just like another storage class. It kinda makes
sense, until you wonder why C...
|
| Show full article (1.07Kb) |
| no comments |
|
  |
|
Author: xushiweixushiwei Date: Apr 21, 2008 22:10
|
| |
| no comments |
|
  |
Author: Chris ThomassonChris Thomasson Date: Apr 22, 2008 09:18
"Chris Thomasson" comcast.net> wrote in message
news:c4Odnch9beA_QJHVnZ2dnUVZ_viunZ2d@comcast.com...
> [...]
>
> AFAICT, your implementation is not thread-safe. For instance, I could not
> use it to implement a producer/consumer pattern. Thread A allocates blocks
> and passes them to thread B which frees them. Am I missing something?
|
| Show full article (1.42Kb) |
| no comments |
|
  |
Author: Lance DiduckLance Diduck Date: Apr 22, 2008 09:40
> On 21 Apr, 19:13, xushiwei gmail.com> wrote:
> I took a quick look with particular interest
> in what you have to say about scoped allocators.
> It seems to me that there is some overlap with
> what you are doing and the work by Pablo Halpern in
> his N2523 submission to WG21 entitled "The Scoped Allocator
> Model". Seehttp://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2523.pdf
>
> IMO Pablo's proposal is more thought through.
> I recommend you take a look.
Pablo doesnt actually propose any allocator. It only mentions a
technique for applying allocators to containers. The only "scoped
allocator" in there is a wrapper around the system allocator.
Pablos work's doesnt mention anything on how to write allocators that
could be scoped. Rather, that if they could be written then this is
how to pass them from one container to another.
And that is the rub-- writing an allocator that could be "scoped" is
very hard indeed. The stated intent of "scoped allocators" is to
change the semantics of STL "regular type" such that any property that ...
|
| Show full article (3.19Kb) |
| no comments |
|
  |
Author: xushiweixushiwei Date: Apr 22, 2008 09:40
>
> I took a quick look with particular interest
> in what you have to say about scoped allocators.
> It seems to me that there is some overlap with
> what you are doing and the work by Pablo Halpern in
> his N2523 submission to WG21 entitled "The Scoped Allocator
> Model". Seehttp://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2523.pdf
>
> IMO Pablo's proposal is more thought through.
> I recommend you take a look.
Before I post this article, I read submissions to WG21 related to
Allocator, such as n1850, n1509, n2387, n2523(n2446), n2436, n2486,
n2524, n2554.
You mentioned "The Scoped Allocator Model", so I read it though again
( http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2523.pdf and
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2446.pdf). I
don't find common points between them except the similar name:-) Would
you point out them for me?
|
| Show full article (4.40Kb) |
| no comments |
|
|
|
|