Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
A memory allocator that automatically reduces the memory footprint of C/C++ applications.
C++ Python C CMake Makefile Dockerfile Shell
Branch: master
Clone or download
emeryberger Changed a comparison with an integer to use == (#66)
Changed a comparison with an integer to use ==
Latest commit 722b05c Jan 31, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows build: fixes for CMake build of executables and GCC build on MacOS (#59) Oct 20, 2019
src common: don't include map Jan 3, 2020
support Changed a comparison with an integer to use == Jan 31, 2020
theory Typo fixes. Feb 18, 2019
.clang-format meshing: clang-fromat Feb 10, 2017
.dockerignore
.editorconfig build: update .editorconfig Oct 21, 2018
.gitattributes build: exclude theory and support directories from linguist Jan 2, 2020
.gitignore Fallocate alternative for Mac, Xcode build, fix cmake cache directory Oct 18, 2019
.gitmodules build: remove aligned alloc dependency (only used in a test) Jan 3, 2020
AUTHORS update copyright header on individual files + add AUTHORS Feb 17, 2019
CMakeLists.txt clean up some unused parameter warnings CMake exposes for some reason Jan 3, 2020
CODE_OF_CONDUCT.md add code of conduct Sep 16, 2019
Dockerfile Dockerfile: fix build when submodules aren't checked out Feb 18, 2019
GNUmakefile test: large-alloc stress test program from #36 Mar 7, 2019
LICENSE LICENSE: add Apache 2 license Feb 17, 2019
Makefile build: remove gflags vendored library Jan 2, 2020
README.md Added video link (maybe). Oct 17, 2019
configure
mesh-pldi19-powers.pdf Added. Sep 19, 2019

README.md

Mesh: Compacting Memory Management for C/C++

Mesh is a drop in replacement for malloc(3) that compacts the heap without rewriting application pointers.

Mesh is described in an academic paper (PDF) that appeared at PLDI 2019.

Or watch this talk by Bobby Powers at Strange Loop:

Compacting the Uncompactable

Mesh runs on Linux; macOS support should be considered alpha-quality, and Windows is a work in progress.

Mesh has a standard C++ build process, and has no runtime dependencies other than libc-related libs:

$ git clone --recurse-submodules https://github.com/plasma-umass/mesh
$ cd mesh
$ ./configure; make; sudo make install
# example: run git with mesh as its allocator:
$ LD_PRELOAD=libmesh.so git status

Please open an issue if you have questions (or issues)!

Implementation Overview

Mesh is built on Heap Layers, an infrastructure for building high performance memory allocators in C++ (see paper for details.)

The entry point of the library is libmesh.cc. This file is where malloc, free and the instantiations of the Heap used for allocating program memory lives.

DEFINITIONS

  • Page: The smallest block of memory managed by the operating system, 4Kb on most architectures. Memory given to the allocator by the operating system is always in multiples of the page size, and aligned to the page size.
  • Span: A contiguous run of 1 or more pages. It is often larger than the page size to account for large allocations and amortize the cost of heap metadata.
  • Arena: A contiguous range of virtual address space we allocate out of. All allocations returned by malloc(3) reside within the arena.
  • GlobalHeap: The global heap carves out the Arena into Spans and performs meshing.
  • MiniHeap: Metadata for a Span -- at any time a live Span has a single MiniHeap owner. For small objects, MiniHeaps have a bitmap to track whether an allocation is live or freed.
  • ThreadLocalHeap: A collections of MiniHeaps and a ShuffleVector so that most allocations and free(3)s can be fast and lock-free.
  • ShuffleVector: A novel data structure that enables randomized allocation with bump-pointer-like speed.
You can’t perform that action at this time.