Boost Memory Library: boost-memory-0.1.01

Exception Semantics

I update GC Allocator specification now. See the example named "testExceptionSemantics".

The following is the new minimum specification for GC Allocator:

typedef void (*DestructorType)(void* data);
concept GCAllocator
    // Allocate memory without given a cleanup function
    void* allocate(size_t cb);
    // Allocate unmanaged memory with a cleanup function
    void* unmanaged_alloc(size_t cb, DestructorType fn);
    // Commit unmanaged memory to be managed.
    void* manage(void* p, destructor_t fn);
    // Deprecated: allocate memory with a cleanup function
    void* allocate(size_t cb, DestructorType fn) {
        return manage(unmanaged_alloc(cb, fn), fn);
    // Cleanup and deallocate all allocated memory by this GC Allocator
    void clear();
    // Swap two GCAllocator instances
    void swap(GCAllocator& o);


Thank Steven Watanabe and Scott McMurray.

Performance Comparison

I toke a performance comparison of

  • boost::memory::auto_alloc
  • boost::memory::scoped_alloc (use tls_block_pool::instance)
  • boost::memory::scoped_alloc
  • boost::memory::gc_alloc (auto)
  • boost::memory::gc_alloc (manually)
  • boost::pool (auto)
  • boost::object_pool (auto)
  • new/delete (gcc)
  • mt_allocator (gnu c++)

Here (auto) means recycling objects when allocators' destructor is called. and (manually) means deleting objects manually.

TestCase: performance.cpp
Output: output.txt

Related Topics

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License

Subscription expired — please renew

Pro account upgrade has expired for this site and the site is now locked. If you are the master administrator for this site, please renew your subscription or delete your outstanding sites or stored files, so that your account fits in the free plan.