Since just before the holidays, Jason and I have been working on getting jemalloc ported to Windows, Mac and Linux as well as integrated in to our build system. Each platform has its own set of challenges, with Windows being the most exciting. I tried several approaches including dynamically patching over the C runtime allocation functions (malloc, free, etc) in memory, but kept running in to issues with the allocations the CRT does during startup. Things like putenv() realloc and free allocations that were done before we had the chance to patch in. I talked to Benjamin about replacing the CRT and he did a bunch of work to get a CRT building with jemalloc. It turned out not to be very difficult — Microsoft includes the source as part of Visual Studio Professional (sadly, you can’t redistribute it). I had to make various changes to the init functions to make sure we could use CRITICAL_SETIONs and thread local storage during malloc initialization. Was a bit of a pain to make sure the malloc initialization code didn’t call things that needed to allocate but eventually I got everything working. The result: A Windows jemalloc build. The sunspider JS test looks to run about 5% faster. You’ll notice that these builds take up a bit more memory initially but they should level out around 80mb. There is plenty of tuning left to do, but I’m curious to hear how these run for people after running for a long time.
Linux builds are stable but I don’t have one handy. Mac builds run for a little while before they crash, but the crash looks like one I fixed on Windows so I expect to have those early next week.