GC Allocator Summary

C++ Memory Management Innovation: GC Allocator

Link: http://www.codeproject.com/KB/cpp/gc-allocator.aspx

Highlights: The tiniest, fastest allocator and easy to use. And it became a boost sandbox library on 2008-04-29. I'm preparing for a peer review.

It is easy to use:

  • Like GC languages (eg. Java, C#, etc), it is no need to delete allocated objects by using GC Allocator.

It is faster than all allocators you ever seen:

peralloc-1000000.png

For the detail information about the comparison, see "Allocators Performance Comparison".

Why GC Allocator is so fast? It benefits from:

  1. Its good allocation algorithm.
  2. No multithread locks.
  3. C++ inline functions.

Is It useful? Yes. we already have applications based on it. Here are some of them:

A Word File Writer

I wrote a word file format writer with GC Allocator. I was excited that It is the fastest word file writer component I ever seen.

Interested in it? See The Fastest Word File Writer.

Rope based on GC Allocator

Rope is a complex string implementation with scaled performance. The original rope implementation is appeared in SGI STL. I rewrite the rope class based on GC Allocator. Code size is much reduced and performance is better.

Interested in it? See Rope on GC Allocator.

STL Containers based on GC Allocator

When we use GC Allocator, performance of STL containers has distinct promotion. Here is one of our test results (in milliseconds):

STLContainers.png
deque list set hash_set map hash_map
ScopeAlloc 5.71 ms 20.32 ms 198.44 ms 129.68 ms 225.12 ms 130.80 ms
STL 8.34 ms 66.56 ms 504.81 ms 232.63 ms 505.34 ms 242.21 ms

For the detail information about the comparison, see "Allocators Performance on STL Collections".

The Fastest Word File Writer

Highlights: It's a fast, full-featured word file format writer. And It also can write RTF files (but I remove this function in the published version provided here). And this version is only for technology show. You can't use it in commercial way.

Why it is fast:

  • First, we use GC Allocator to accelerate memory allocation.
  • Second, we create a DOM tree which its internal data structures is similar to word file format. It provides powerful APIs and reduces IO times.

Full-featured:

  • Yes. It can write all word2003 functions such as rich text, font/stylesheet, bullet/list, header/footer, footnote/endnote, fields, bookmark, annotation, frame, table, drawing (including picture, textbox, group shape, ole, etc), revision, and more.
  • You can choose save as a word file, or a RTF file. And It's easy to support a new file format because our DOM tree also provided reading APIs to access all data.
  • Demo applications are provided. Please see "The fastest word file writer".
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License