Skip to content

Instantly share code, notes, and snippets.

View riesentoaster's full-sized avatar

Valentin Huber riesentoaster

View GitHub Profile
@riesentoaster
riesentoaster / swapcheck.sh
Created July 9, 2021 11:42
Script that dumps the contents of top shortly after the computer starts to swap
#!/bin/bash
# start with nohup ./swapcheck.sh & echo $! >> pid.txt
echo "Tracking swap..." >> out.txt
while [[ $(top -l 1 -o mem -n 0 | grep -o -E '.{0,6}swapins' | cut -c 1) == " " ]]
do
sleep 1
done
date >> out.txt
echo "
@riesentoaster
riesentoaster / makemeswap.c
Created July 9, 2021 11:36
Short code snippet that forces a computer to swap.
#include <stdlib.h>
#include <math.h>
/* This short program fills RAM in 1GB chunks with random data to make a computer swap */
int main(int argc, char const *argv[])
{
while (1)
{
unsigned long amount = pow(2, 3 * 10); /* 1 GB */