How can I get the memory that my Java program uses via Java’s Runtime api?
You’re doing it correctly. The way to get memory usage is exactly as you described: Runtime.getRuntime().totalMemory() – Runtime.getRuntime().freeMemory() But the reason your program always returns the same memory usage is because you are not creating enough objects to overcome the precision limitations of the freeMemory method. Although it has byte resolution, there is no guarantee … Read more