Re: C++ Memory Management Innovation: GC Allocator
Home
FAQ
Contact
Sign in
Search
comp.lang.c++.moderated only
Advanced search
POPULAR GROUPS
perl.cpan.testers
alt.bestjobsusa.computer
alt.bestjobsusa.computer.jobs
us.jobs
us.jobs.offered
alt.bestjobsusa.jobs.offered
news.admin.netabuse.sightings
alt.politics
it.politica
alt.fan.rushlimbaugh
more...
Up
Re: C++ Memory Management Innovation: GC Allocator
Group:
comp.lang.c++.moderated
·
Group Profile
Author:
xushiwei
xushiwei
Date:
May 8, 2008 01:30
> Had a look at your code... Looks unnecessarily complicated to me. Here
> is the result of about 15 minutes of work:
>
> [code]
> #include
> #include
>
> using namespace std;
>
> struct FastAlloc
> {
> struct Block
> {
> unsigned char memory[1024];
> };
> deque
m_pool;
> size_t m_left;
>
> FastAlloc() : m_left(0) {}
>
> void* allocate(size_t size)
> {
> assert(size <= 1024);
> if (size > m_left)
> {
> m_pool.resize(m_pool.size() + 1);
> m_left = 1024;
> }
>
> void* res = m_pool.back().memory + 1024 - m_left;
> m_left -= size;
> return res;
> }
>
> };
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 <
http://tinyurl.com/65k728
>
Output: output.txt <
http://tinyurl.com/5rzg2c
>
See:
http://winx.googlecode.com/svn/tags/boost-memory-0.1.01
/
--
[ See
http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
no comments
diggit!
del.icio.us!
reddit!