I use the following lines to get the memory usage with Java :
Free_Memory=Run_Time.freeMemory()/1048576; // 1024 x 1024 = 1K x 1K = 1Meg
Total_Memory=Run_Time.totalMemory()/1048576; // 992 Total on a 4 GB PC
The Free_Memory I got was : 900, but it is way off, when Free_Memory goes down to around 600, my program ran out of memory and generated heap overflow message.
So I looked at the => Windows Task Manager : Performance : Physical Memory : Free, it's down to 1, 2 or 0, which is a more accurate reflection of my memory situation, and according to it, my Total Memory is : 4089, which is correct, while Java's Total_Memory=992 is incorrect.
So, my question now is : In my Java program how to get the memory usage numbers reflected in the Windows Task Manager : Performance : Physical Memory ? I need to depend on those numbers.