-2

What's the difference between freeMemory() and totalMemory()? Both are the total amount of memory currently available for JVM.

    /**
     *
     * @return  an approximation to the total amount of memory currently
     *          available for future allocated objects, measured in bytes.
     */
    public native long freeMemory();

    /**
     *
     * @return  the total amount of memory currently available for current
     *          and future objects, measured in bytes.
     */
    public native long totalMemory();
Slaw
  • 37,820
  • 8
  • 53
  • 80
user697911
  • 10,043
  • 25
  • 95
  • 169
  • It's about "future" vs "current and future" – ernest_k Nov 03 '18 at 03:54
  • FreeStaturdayTime() - number of hours available (not yet planned!) to do stuff this Saturday, TotalSaturdayTime() - number of hours you'll be awake this Saturday (no staying up later than already decided by your significant other / cat!). – user2864740 Nov 03 '18 at 04:18

1 Answers1

0

freeMemory() says for future, and totalMemory() says for current and future.

Literally, freeMemory() tells the memory for new allocating objects and totalMemory() tells the total memory (memory already allocated + free memory)

Hyun I Kim
  • 589
  • 1
  • 3
  • 14