Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Architecture: Memory Allocation

pgoodman edited this page Sep 6, 2014 · 7 revisions

Granary's OS interface provides one and only one mechanism of getting new memory: granary::os::AllocatePages, defined in os/linux/*/memory.cc. This function will return a pointer to the beginning of several pages of memory. In user space, AllocatePages uses an mmap system call to request memory from the host OS. In kernel space, AllocatePages serves pages from a pre-allocated fixed-size memory pool.

Several allocators are defined on top of this simple interface. The most widely used kind of allocator is the type-specific allocator. There are also block meta-data allocators, which use a form of "late bound" type-specific allocator, and code cache allocators.

Type-Specific Allocators

The type-specific allocators are implemented in granary/base/new.h and granary/base/new.cc, respectively.

Type-specific allocators can only be used for C++ classes, as they overload operator new and operator delete.

Note: Type-specific allocators do not support operator new[] or operator delete[].

Block Meta-data Allocator

Code Cache Allocator