Memstop: Use LD_PRELOAD to delay process execution when low on memory
10 months ago
- #linux
- #parallel-processing
- #memory-management
- Memstop is a lightweight LD_PRELOAD shared object that delays process execution when system memory is critically low.
- It monitors available memory and waits until a configurable percentage is available before allowing the application to start.
- Designed to prevent crashes caused by memory exhaustion in parallel processing systems.
- Useful in parallel build systems (like make -j), batch processing systems, and high-memory applications.
- When loaded via LD_PRELOAD, it runs before the application's main() function and all subprocesses.
- Reads system memory from /proc/meminfo, calculates required available memory (default: 10%), and waits until conditions are met.
- Build requirements: GCC compiler, Linux system with /proc/meminfo support, and Make.
- Installation involves building the shared library (memstop.so) and placing it in a library path.
- Configured using environment variables: MEMSTOP_PERCENT (default: 10, range: 0-100) and MEMSTOP_VERBOSE (for verbose output).
- Verbose mode outputs memory statistics and blocking status but can interfere with normal execution.
- Licensed under GNU General Public License v3.0 (GPLv3).