Last active
December 15, 2023 01:00
-
-
Save analogue/fae3d434432920eacb6add373a0609eb to your computer and use it in GitHub Desktop.
eatmemory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Spawn a process that eats memory by the gigabyte. | |
# Useful for testing ulimits and other such nonsense. | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <gigabytes>" | |
exit 1 | |
fi | |
gigabytes_to_allocate=$1 | |
bytes_to_allocate=$((gigabytes_to_allocate * 1024 * 1024 * 1024)) | |
echo "Allocating $gigabytes_to_allocate GB of memory...Ctrl-C to exit" | |
</dev/zero head -c $bytes_to_allocate | tail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment