Current memory
Using adb command to detect current memory usage.
adb shell dumpsys meminfo your_app_name
Peak memory
Using following script to detect memory many times, and to count the peak memory usage.
MAX_MEM=0
COUNT=0
LOOP_NUM=10000
if [ -n "$1" ]; then
LOOP_NUM=$1
fi
while [ $COUNT -lt $LOOP_NUM ]
do
MEM=$(adb shell dumpsys meminfo your_app_name | grep 'TOTAL PSS:' | awk -F ':' '{print $2}' | awk '{print $1}')
COUNT=`expr $COUNT + 1`
if [[ "$MEM" > "$MAX_MEM" ]]; then
MAX_MEM=$MEM
echo $COUNT: MAX_MEM=$MAX_MEM
fi
sleep 0.01
done