Skip to content
Purgeable memory allocations for Linux
C Makefile
Branch: master
Clone or download
Latest commit a95b054 Dec 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Makefile
README.md
UNLICENSE
hog.c
purgeable.c
purgeable.h
test.c

README.md

Purgeable Memory Allocations for Linux

Purgeable memory is a contiguous allocation that can be reclaimed by the kernel at any time while unlocked. Before accessing or using the allocation, it must be locked, and then unlocked when no longer in active use. See purgeable.h for API documentation.

Full article: Purgeable Memory Allocations for Linux

void *purgeable_alloc(size_t);
void  purgeable_unlock(void *);
void *purgeable_lock(void *);
void  purgeable_free(void *);

This idea was inspired by OS hacking: Purgeable memory (discussion).

To test it out, disable swap (swapoff), run one or more instances of test, then run hog. As hog consumes more and more memory (before being killed by the OOM killer), instances of test will see their regions get reclaimed and exit.

You can’t perform that action at this time.