-
Notifications
You must be signed in to change notification settings - Fork 5
Architecture: Memory Allocation
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.
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[]
.