Skip to content

gaoxiaojun/mmap_lowmem

 
 

Repository files navigation

About

This is a wrapper for mmap() to expand the address range of the MAP_32BIT flag from 31bits to a full 32bits (i.e. the low 4Gbytes). This allows access the almost a full 4Gbytes of 32bit addresses.

The main use of this wrapper is to allow LuaJIT to use more then 1Gbyte of ram on Linux. With this wrapper LuaJIT can use amost a full 4Gbytes of ram.

Compile

$ make

Usage

Dynamically during run-time

None thread-safe version:

$ LD_PRELOAD="./libmmap_lowmem.so" luajit-2

Or link luajit-2 with libmmap_lowmem.so

Thread-safe version:

$ LD_PRELOAD="./libmmap_lowmem_mt.so" luajit-2

Or link luajit-2 with libmmap_lowmem_mt.so

Getting every last bit of the low 4Gbytes available

Compiling the LuaJIT executable as a position-independent executable will move the program brk (used by malloc) to an address outside the low 4Gbytes.

Use this make command to build LuaJIT:

$ make all LDFLAGS=" -pie " CFLAGS=" -fPIC "

TODO

  • Handle MREMAP_MAYMOVE & MREMAP_FIXED flags for mremap wrapper.
  • Valgrind support.
  • Cleanup code.

About

mmap() wrapper to expand MAP_32BIT to use all of the low 4Gbytes of address space.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published