summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmemory-take18
-rwxr-xr-xmemory-usage11
2 files changed, 29 insertions, 0 deletions
diff --git a/memory-take b/memory-take
new file mode 100755
index 0000000..57289a5
--- /dev/null
+++ b/memory-take
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+import sys
+import time
+
+if len(sys.argv) != 2:
+ print "usage: fillmem <number-of-megabytes>"
+ sys.exit()
+
+count = int(sys.argv[1])
+
+megabyte = (0,) * (1024 * 1024 / 8)
+
+data = megabyte * count
+
+while True:
+ time.sleep(1)
+
diff --git a/memory-usage b/memory-usage
new file mode 100755
index 0000000..5c2104f
--- /dev/null
+++ b/memory-usage
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+"$@" &
+pid=$! peak=0
+while true; do
+ sleep 1
+ sample="$(ps -o rss= $pid 2> /dev/null)" || break
+ let peak='sample > peak ? sample : peak'
+done
+echo "$(( ${peak%% *} / 1024)) m"
+