<%@ page title="" language="C#" masterpagefile="~/MasterPage.master" autoeventwireup="true" inherits="issue1_win32memalloc, App_Web_w3f1bb6p" %> The Treatyist - Windows Memory Allocation Performance

Comparing the Performance of Various Memory Allocators in C++ Native Code for 32 Bit Windows

Results

On a relatively unburdened dual processor Opteron 270 based machine, we find that C++ new and Win32 HeapAlloc offer very close performance, turning in around 1300 allocations per millisecond. This is no surprise as these days, new is often written in using HeapAlloc. For the case of building large strings or binary blobs, without the need to reallocate something, incrementing a pointer in a giant block returned by VirtualAlloc can be much faster, providing more 75,000 allocations per millisecond.

The Visual C++ 2008 solution file can be downloaded from Memory Performance

Background

With today's modern hardware, we tend to assume that very fast is fast enough. Sometimes it is useful to know, how fast can we really go. While 1300 allocations per millisecond is quick, it is only about 1.3 million allocations per second. This is useful to know.

If a database table were being uploaded from the internet, and each field were an allocated string, the memory allocator would be a drag on the overall system performance. This would be the case with XML or HTML downloads, complex image nodes, any tree structure where a standard memory allocator is used and the size of the allocated node is small.