> I'm looking for a way to quickly allocate a high number of small objects > on the heap. I have attached a sample program with what I'm trying to > do; when I allocate a vector of objects it's hundreds of times faster > than allocating a vector of pointers and new()'ing every object. That is > to be expected of course, I was just wondering if there is a way to > speed things up (ie, allocate a bunch of memory, and have the pointers > in my vector point to it). I hope I explained myself clearly; the code > will illustrate, I think.
Unless I've misunderstood how it works, you can write an overloaded 'operator new' for your object and let it "allocate" chunks from your pool instead of the normal route; thus, it basically sets your pointers to point into that pool each time rather than doing any actual allocation. Of course, if you need to be able to delete them and re-allocate during the life of the program, then you will need a small amount of memory management code to mark chunks in your pool as allocated or free, and thus decide where the next free chunk is. -- Jason Teagle [EMAIL PROTECTED]
