Sign in to follow this  

Memory Allocation Optimization

Recommended Posts

Well, after scouring the net looking for good examples: comparing the performance of dynamic memory allocation versus. 'quasi' pre-allocation schemes, I came back empty handed. Spending a couple hours I wrote up two classes: AllocTable AllocPaged These allocate fixed size AllocdThing class objects using simple New() and Delete() function calls. Then I benched them using this method: Built a random sequence of 65k unsigned short ints. Looped through them 500,000 times to get the current operation. 50% of the operations modified random allocated objects. 25% of the operations allocated new objects. 25% of the operations de-allocated random objects. The test was looped 10 times (since I use the time.h clock() funcs and need to strip out inaccuracy) and the median taken. End result: Averaged ratio: Paged is 1.7 times faster than Tabled. So, using something the tries to replicate actual object use, it *looks like* pre-allocated pages of objects are roughly 70% faster than dynamically allocated ones. The source can be found here: (main.cpp, alloc.h, alloc.cpp) AllocTest.rar

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this