I need the best way to get the SUM of the total RAM usage for a given UID (Unix).
It will always be pretty inaccurate because of shared pages. However smem should be able to generate you such report.
As Michal says, this will be inaccurate due to shared pages, but if you wanted to you could build a script around a ps command
For example the couple of liner below would print out the virtual memory used by the UID 500 in KB:
#!/bin/bash SUM=0 for MEM in `ps -u 500 -o vsize --no-headers`; do SUM=$((SUM+$MEM)); done echo $SUM
I believe atop can do per-user statistics.