allocating memory above 2GB

Evan Wies evan at
Fri Feb 14 13:52:40 PST 2014


Is it possible to allocate memory in a defined region, specifically 
anywhere above the first 2GB?

I see that mallocx with ALLOCM_ALIGN allows one to specify a base 
address aligned to a power of 2.  Can I grab a bunch of memory that way 
and somehow tell an arena to use that space and then always mallocx with 
that arena?

I'm in the midst of writing a LuaJIT [1] binding to jemalloc, and have 
successfully allocated memory aligned to 2^31 but can't figure out the 
next step -- short of writing my own allocator to dole out 
jemalloc-allocated memory.

LuaJIT, a Lua Just-In-Time compiler, can itself only allocate memory in 
the lower portions of memory (<1GB, <2GB, <4GB depending on platform).   
One can get around this limitation by using its FFI to allocate memory 
for FFI-bound C structures, however allocating these in the lower 
regions effectively "steals" available memory from the LuaJIT VM for Lua 
objects.   I want to ensure maximum available memory for the LuaJIT by 
allocating all my objects outside this area.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the jemalloc-discuss mailing list