i have a list of simples pojos (a User class) with about 15 simple fields & 1 arrayList. Those represent users & maybe 100 or 1000 of them will be store in memory in
If you want a simple test, you can set the new size to be large and do the following. This only works if your new size is much larger than the data you are creating. e.g.
-XX:NewSize=1g -verbosegc
The value will be correct provided you don't see any GC.
long before = Runtime.getRuntime().freeMemory();
//build object here
long used = before - Runtime.getRuntime().freeMemory();
Note: this assumes you don't generate an temporary objects.