Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.
Yuri Voinov edited this page Sep 21, 2024 · 11 revisions

To build memproxy in dual ABI environments (32/64 bit) use the following commands:

# 64 bit (GCC, most platforms)
./configure 'CXXFLAGS=-m64' --libdir=/usr/local/lib/64

make clean && make && make install-strip

# 32 bit
./configure 'CXXFLAGS=-m32' --libdir=/usr/local/lib

make clean && make && make install-strip

It may also be necessary to create symlinks in system/trusted library directories for simplified preloading without the full absolute path and auto-selecting the appropriate bit on preloading as follows:

export LD_PRELOAD=libmemproxy.so

Both builds will share a common configuration file.

Note: In case of configuration errors, a fallback to the default libc occurs. No error messages are displayed. Except for relatively rare incompatibilities, segfaults do not occur.

Note: On most systems, libc.so is either a symbolic or hard link to the latest version. On OpenBSD, there are no links and you may need to edit the library name. Keep in mind that when upgrading OpenBSD, previous versions of libc may be preserved and you should check and select the latest version when building.

Note: On some OS (e.g. Solaris) you can specify a symbolic link (i.e. /usr/lib/amd64/libc.so) when preloading libc. However, this method does not work on Linux and results in an error like:

ERROR: ld.so: object '/usr/lib/libc.so' from /etc/ld.so.preload cannot be preloaded (invalid ELF header): ignored.

In this case, you need to specify the file name instead of the link name (/usr/lib/libc.so.6).


To use with jemalloc, redefine these macros in memproxy.h as shown below and recompile. To work with other allocators, use a similar approach.

// jemalloc API function names
// Note: Do not define interposed malloc/realloc/free etc. Use internal API instead
#define CUSTOM_MALLOC   "je_malloc"
#define CUSTOM_REALLOC  "je_realloc"
#define CUSTOM_CALLOC   "je_calloc"
#define CUSTOM_FREE     "je_free"
#define CUSTOM_MEMALIGN "je_posix_memalign"
#define CUSTOM_SIZE     "je_malloc_usable_size"
#define CUSTOM_TRIM     ""	// jemalloc has no malloc_trim function

Clone this wiki locally