Skip to content

Instantly share code, notes, and snippets.

@analogue
analogue / eatmemory.sh
Last active December 15, 2023 01:00
eatmemory
#!/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))
@analogue
analogue / stracetree.py
Created June 23, 2015 18:11
strace an existing process tree
#!/usr/bin/python
# strace an existing process tree. `strace -f` only follows newly spawned
# processes which is not always what you want.
import os
import sys
import subprocess
# /proc/[pid]/task/* == directory of threads including self
# /proc/[pid]/task/[pid]/children == child processes