#!/bin/bash
#
# Outputs the memory usage of the process every 0.05 second
# Usage: appmem.sh appname1 appname2 
#
timestamp=$(date +%s)
if [ $# -gt 0 ]
then
    while [ 1 ]
    do
        for appname in "$@"
        do
            val=$(ps -C $appname -o rss,vsize h)
            if [ $? -eq 1 ]; then
                val=0
            fi
            echo $appname $val >> ${appname}-${timestamp}.memlog
        done
        sleep 0.05
    done
fi

