Memstop A lightweight LD_PRELOAD shared object that delays process execution when system memory is critically low. Memstop monitors available memory and waits until a configurable percentage of memory becomes available before allowing the application to start. Purpose Memstop is designed to prevent crashes caused by memory exhaustion in parallel processing systems. It can be particularly useful in: Parallel build systems (like make -j ) where you want to prevent the build from failing due to the OOM (out-of-memory) killer ) where you want to prevent the build from failing due to the OOM (out-of-memory) killer Batch processing systems where you want to ensure adequate memory before starting jobs High-memory applications that might crash the system if started when memory is low How It Works When loaded as a shared object (via LD_PRELOAD ), memstop automatically runs before your application's and all subprocesses' main() functions. It: Reads system memory information from /proc/meminfo Calculates the required available memory percentage (default: 10%) Waits until the specified percentage of memory is available Releases control to your application once memory requirements are met Build Prerequisites GCC compiler Linux system with /proc/meminfo support support Make Building from Source # Build the shared library make # The build creates memstop.so Install System-wide Installation # Install to /usr/local/lib (requires root privileges) sudo make install Manual Installation # Copy to a directory in your library path cp memstop.so /path/to/your/lib/directory Usage Basic Usage Use LD_PRELOAD to load memstop before running your build process: LD_PRELOAD=/usr/local/lib/memstop.so make -j Configuration Memstop is configured using environment variables: Sets the percentage of total memory that must be available before allowing execution. # Require 20% of total memory to be available before make can spawn a task MEMSTOP_PERCENT=20 LD_PRELOAD=/usr/local/lib/memstop.so make -j # Req...
First seen: 2025-07-08 15:31
Last seen: 2025-07-08 19:31