Hacker News new | ask | show | jobs
by MaulingMonkey 1856 days ago
> On windows I'd expect the default allocator to be a black box, but I might be wrong.

The UCRT is at least "source available" on Windows, up to a point, and distributed with the Windows SDK. The release heap codepath is a bit boring:

    malloc:       C:\Program Files (x86)\Windows Kits\10\Source\10.0.19041.0\ucrt\heap\malloc.cpp
    _malloc_base: C:\Program Files (x86)\Windows Kits\10\Source\10.0.19041.0\ucrt\heap\malloc_base.cpp
    HeapAlloc:    (kernel32.dll alias for ntdll.dll!RtlAllocateHeap() on my machine)
The debug codepath is a bit more interesting:

    malloc:                  C:\Program Files (x86)\Windows Kits\10\Source\10.0.19041.0\ucrt\heap\malloc.cpp
    _malloc_dbg:             C:\Program Files (x86)\Windows Kits\10\Source\10.0.19041.0\ucrt\heap\debug_heap.cpp
    heap_alloc_dbg:          C:\Program Files (x86)\Windows Kits\10\Source\10.0.19041.0\ucrt\heap\debug_heap.cpp
    heap_alloc_dbg_internal: C:\Program Files (x86)\Windows Kits\10\Source\10.0.19041.0\ucrt\heap\debug_heap.cpp
    HeapAlloc
HeapAlloc itself is a bit more of a black box (AFAIK), and contains a lot of the fun details about the actual process of heap allocation - although there's a bunch of hooks, debug functions, documentation, articles, alternative implementations (ReactOS), etc.
1 comments

Thanks! I was wrong then.