Class size and performance

Unknown W. Brackets unknown at simplemachines.org
Sun Jan 20 20:04:58 PST 2008


That's a good trick, but it's probably not helpful in this case.  My 
problem is, I know that I'm going to have 1000 of these objects. 
There's no reason to allocate each one individually.  Rather I should 
create a pool for them, and shove the instances into the pool.

Free lists are great when I'm going to be trashing objects frequently. 
My problem is I have 1000 objects I need to create, and end with.  And, 
if I ever delete any of those, the largest possibility is that I'm 
deleting all of them.

Since my problem (of this thread) appears to be doubling the size of 
allocation due to passing 64 bytes, this should allow me to better 
manage the memory.  I'm not sure if I want to pack it within my buffer 
or do it every 128 bytes (which might be better alignment), but either 
way less allocations will - I'm hoping - improve speed.

I'll have to play with a few different things.

-[Unknown]


torhu wrote:
> One trick Walter uses in DMD is free lists, did you check out that? 
> Obviously it won't work if you need all of the objects allocated at the 
> same time.
> 
> http://www.digitalmars.com/d/memory.html#freelists


More information about the Digitalmars-d-learn mailing list