A cross-platform memory allocation utility written in C that allocates memory in fixed-size chunks until either memory is exhausted or a configurable maximum limit is reached. Perfect for stress testing, memory analysis, and system resource evaluation.
- Configurable chunk allocation: Set custom chunk sizes (default: 100MB)
- Memory limit control: Set maximum allocation limits with MB/GB unit support
- Speed modes: Choose between aggressive (fast) or gentle (delayed) allocation
- Progress tracking: Real-time logging of allocation progress
- Graceful shutdown: Clean memory release on Ctrl+C interruption
- Cross-platform: Compatible with Windows, Linux, and macOS
- Error handling: Robust malloc failure detection and recovery
- Memory persistence: Holds allocated memory indefinitely until termination
Clone the repository and compile the program:
git clone https://github.com/elxecutor/ram-hog.git
cd ram-hog
gcc -O2 ramhog.c -o ramhog
-
Basic usage (allocate 100MB chunks until memory exhausted):
./ramhog
-
Custom chunk size (50MB chunks):
./ramhog -c 50
-
Set allocation limit (allocate up to 2GB):
./ramhog -m 2G
-
Gentle allocation mode (100ms delay between chunks):
./ramhog -s gentle
-
Combined options:
./ramhog -c 25 -m 1G -s aggressive
-
View help:
./ramhog --help
-c, --chunk-size SIZE
: Chunk size in MB (default: 100)-m, --max-alloc SIZE
: Maximum allocation (MB/GB, 0=unlimited, default: 0)-s, --speed MODE
: Allocation speed:aggressive
orgentle
(default: aggressive)-h, --help
: Show help message
100
- 100 MB2G
- 2 GB1024M
- 1024 MB
We welcome contributions! Please see our Contributing Guidelines and Code of Conduct for details.
This project is licensed under the MIT License.
For questions or support, please open an issue or contact the maintainer via X.