✔ 最佳答案
There just one Runtime object for a running Java application, and you can get a reference to that object with Runtime.getRuntime().
You can use this each time you want to refer to that object, with something like:
long total = Runtime.getRuntime().totalMemory();
long free = Runtime.getRuntime().freeMemory();
Another option is to call getRuntime() once and save the reference:
Runtime rt = Runtime.getRuntime();
...and then later use that reference:
long total = rt.totalMemory();
long free = rt.freeMemory();