Skip to content

Commit

Permalink
kill_high_mem.sh mmx_node 8192
Browse files Browse the repository at this point in the history
  • Loading branch information
madMAx43v3r committed Oct 31, 2022
1 parent 345a9f5 commit 10de04a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions run_gdb_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

source ./activate.sh

./scripts/kill_high_mem.sh mmx_node 8192 &

gdb -ex=run --args ./build/mmx_node -c config/${NETWORK}/ config/node/ "${MMX_HOME}config/local/" $@

kill $(jobs -p)
16 changes: 16 additions & 0 deletions scripts/kill_high_mem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

while true;
do
PID=$(pgrep $1)
if [ ! -e $PID ]; then
SIZE=$(ps -q $PID -o rss=)
SIZEMB=$((SIZE/1024))
if [ $SIZEMB -gt $2 ]; then
printf "Maximum memory of $2 MB exceeded: $SIZEMB MB\nTerminating process ..."
kill $PID
exit 0
fi
fi
sleep 1
done

0 comments on commit 10de04a

Please sign in to comment.