Original Post
I've written my own version of a basic heap, that just allocates a large block of memory from the OS on creation, and then just keeps a list of allocated and free blocks, and divvies them up when I ask. I just timed allocating using my own heap as opposed to new and malloc. I was under the impression that allocating from the OS was slow due to the time it takes for the OS to allocate a page. It seems that I was either wrong, or I just write terrible, terrible code :D Allocating 1024 blocks of 1mb each (1gb): new: 1.692 sec malloc: 1.602 sec my heap: 2.457 sec Allocating 10,000 blocks of 1k each (1gb): new: 0.086 sec malloc: 0.086 sec my heap: 2.211 sec Allocating 100,000 blocks of 100 bytes each: new: 0.563 sec malloc: 0.540 sec my heap: ... got tired of waiting Allocating 1,048,576 blocks of 1k each (~1.1gb): new: 10.016 sec malloc: 9.988 sec my heap: ... i got tired of waiting I'll do some more in depth profiling around the larger blocks of code in the allocate function for my own heap, but it looks like (as expected) it's the increase in the number of allocations that is the problem. I suspect because I'm using a linked list of the free blocks and another linked list of the allocated blocks, the cache is getting a beating. Anyone have any more advice? Is this just going to be the same case as most of the other std C lib code where unless I'm writing for something really specialized, my code is almost always going to be slower?