{"id":5260,"date":"2014-03-30T20:03:33","date_gmt":"2014-03-30T20:03:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-get-free-memory-info-from-java-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:03:33","modified_gmt":"2014-03-30T20:03:33","slug":"how-to-get-free-memory-info-from-java-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-get-free-memory-info-from-java-collection-of-common-programming-errors\/","title":{"rendered":"How to get free memory info from Java-Collection of common programming errors"},"content":{"rendered":"<p>I use the following lines to get the memory usage with Java :<\/p>\n<pre><code>Free_Memory=Run_Time.freeMemory()\/1048576;           \/\/ 1024 x 1024 = 1K x 1K = 1Meg\nTotal_Memory=Run_Time.totalMemory()\/1048576;         \/\/ 992 Total on a 4 GB PC\n<\/code><\/pre>\n<p>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.<\/p>\n<p>So I looked at the =&gt; Windows Task Manager : Performance : Physical Memory : Free, it&#8217;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&#8217;s Total_Memory=992 is incorrect.<\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5260","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5260"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5260\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}