By Alvin Alexander. Last updated: July 20, 2019
Very briefly, I spent a little time today trying to understand how much memory/RAM a Java/Swing application was really using, and these are my notes from that excursion. Note that the app is bundled as a MacOS/Java app I named AlPad, but from some system perspectives it is only seen by the name JavaAppLauncher. Here are my notes, which will hopefully be useful to me in the future:
Seeing the memory used by an individual MacOS app/process
=========================================================
https://superuser.com/questions/700126/how-can-i-monitor-memory-usage-of-a-process-running-from-the-terminal-in-osx
$ top -l 1 | grep JavaApp | awk '{print "NAME="$2 " MEM="$9 "\tRPRVT="$10}'
NAME=JavaAppLauncher MEM=2212K+ RPRVT=0B
https://apple.stackexchange.com/questions/81838/how-to-find-out-which-process-eats-up-memory
--------------------------------------------------------------------------------------------
> sudo ps -awxm -o %mem,rss,comm | sort -nr | grep AlPad
%mem rss comm
0.7 115576 /Users/al/Desktop/My-Dock-Apps/AlPad.app/Contents/MacOS/JavaAppLauncher
found this command elsewhere. didn’t help today, maybe look into it more:
ps -o pid,ucomm,rss
SORT top BY RSIZE
-----------------
top -o -rsize
htop (installed with Homebrew)
------------------------------
- https://hisham.hm/htop/index.php
- shows RES column w/ AlPad at 113MB
- nice ui
time -l
-------
/usr/bin/time -l <DO SOMETHING>
0.04 real
0.00 user
0.00 sys
2830336 maximum resident set size <-- peak memory usage
0 average shared memory size
0 average unshared data size
0 average unshared stack size
462 page reclaims
253 page faults
Resident Set Size in Mac OS X
-----------------------------
http://miknight.blogspot.com/2005/11/resident-set-size-in-mac-os-x.html
A process lives in its own segment of virtual memory. Not all of this virtual memory
is in RAM though. The 'bits' (typically called 'pages') that are in RAM make up
what is known as the resident set size (RSS) of a process. As a process runs, the
active parts need to be brought into RAM, becoming part of the RSS.
Wikipedia: In computing, resident set size (RSS) is the portion of memory occupied
by a process that is held in main memory (RAM). The rest of the occupied memory
exists in the swap space or file system, either because some parts of the occupied
memory were paged out, or because some parts of the executable were never loaded.
Again, these are just some raw notes I kept as I was looking into MacOS process memory use. There is a weird thing where my Java/Swing app shows this kind of memory use, but MacOS is showing a much larger number:
Memory Stats: ------------- Used: 11 MB Free: 52 MB Total: 64 MB Max: 128 MB
It’s been a while since I last looked into Java/JVM memory use, hence these notes.