{"id":1198,"date":"2009-09-25T22:40:08","date_gmt":"2009-09-26T03:40:08","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=1198"},"modified":"2011-08-02T09:23:45","modified_gmt":"2011-08-02T14:23:45","slug":"jvm","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=1198","title":{"rendered":"JVM 1.5"},"content":{"rendered":"<span id=\"Intro\"><h2>Intro<\/h2><\/span>\n<span id=\"JVM\"><h3>JVM<\/h3><\/span>\n<p>* myfile.java &#8212; Compiler (javac) &#8211;> Byte code &#8212; java.exe &#8211;> JVM &#8212; OS &#8211;> Native code<\/p>\n<span id=\"GC\"><h3>GC<\/h3><\/span>\n<span id=\"Sun_JVM_is_generational_and_divides_heap_into\"><h4>Sun JVM is generational and divides heap into<\/h4><\/span>\n<p>* Young Generation<br \/>\n&#8211; Eden Space<br \/>\n&#8211; Survivor Space 0 (aka From Space)<br \/>\n&#8211; Survivor Space 1 (aka To Space)<br \/>\n* Old Generation<br \/>\n* Permanent Generation: holds class files<\/p>\n<span id=\"GC_Process\"><h4>GC Process<\/h4><\/span>\n<p>* All objects are created in Eden Space<br \/>\n* When Eden Space fills up, JVM triggers a minor GC:<br \/>\n&#8211; All unreferenced objects in Eden Space are freed<br \/>\n&#8211; All live objects are copies to S0 until S0 is full. Left over objects are copied to Old Generation.<br \/>\n* When Old Generation fills up, JVM triggers a major GC, aka mark-and-sweep:<br \/>\n&#8211; All threads are frozen<br \/>\n&#8211; All unreachable objects in Old Generation are freed (construct root-set, reachability test, free unreachable objects, defragment heap)<\/p>\n<span id=\"JVM_Parameters\"><h4>JVM Parameters<\/h4><\/span>\n<p>-Xmx<n>m    # Max heap in mb<br \/>\n-Xms<n>m    # Min heap in mb<br \/>\n-XX:NewSize=<n>m    # Young generation size in mb<br \/>\n-XX:MaxNewSize=<n>m    # Max young generation size in mb<br \/>\n-XX:SurvivorRatio=<n>    # Eden to survivor ratio<br \/>\n-XX:PermSize=<n>m    # Initial permanent generation size<br \/>\n-XX:MaxPermSize=NNNm    # Max permanent generation size<\/p>\n<span id=\"Configure_Web_Based_Application_JVM_Heap\"><h4>Configure Web Based Application JVM Heap<\/h4><\/span>\n<p>* Young Generation = 3\/8 Heap<br \/>\n* S0 = 1\/6 Young Generation<br \/>\n* S1 = 1\/20 Young Generation<\/p>\n<pre>\r\njava -Xmx1024m -Xms1024m -XX:NewSize=448m -XX:MaxNewSize=448m -XX:SurvivorRatio=6 -XX:PermSize=128m -XX:MaxPermSize=128m\r\n<\/pre>\n<span id=\"Garbage_Collector_Policy\"><h4>Garbage Collector Policy<\/h4><\/span>\n<p>* The -XX:+UseParallelGC parallel (throughput) garbage collector<br \/>\n* The -XX:+UseConcMarkSweepGC concurrent (low pause time) garbage collector (also known as CMS)<br \/>\n* The -XX:+UseSerialGC serial garbage collector (for smaller applications and systems) <\/p>\n<span id=\"Visual_GC\"><h2>Visual GC<\/h2><\/span>\n<p>* Download Visual GC from <a href=\"http:\/\/java.sun.com\/performance\/jvmstat\/#Download\">http:\/\/java.sun.com\/performance\/jvmstat\/#Download<\/a><br \/>\n* Unzip<br \/>\n* Set JVMSTAT_JAVA_HOME env <\/p>\n<pre>set JVMSTAT_JAVA_HOME=\"C:\\Program Files\\Java\\jdk1.5.0_14\"<\/pre>\n<p>* Make sure java -version returns 1.5 or higher<\/p>\n<pre>\r\nC:\\WINDOWS\\system32>java -version\r\njava version \"1.5.0_14\"\r\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)\r\nJava HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode)\r\n<\/pre>\n<p>* Find jvmid with jps command<\/p>\n<pre>\r\njps\r\n4964 SoapUI\r\n6024 Jps\r\n1224 Bootstrap\r\n<\/pre>\n<p>* Launch VisualGC<\/p>\n<pre>visualgc.cmd 1224<\/pre>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p><a href=\"http:\/\/www.informit.com\/guides\/content.aspx?g=java&#038;seqNum=253\">http:\/\/www.informit.com\/guides\/content.aspx?g=java&#038;seqNum=253<\/a><br \/>\n<a href=\"http:\/\/java.sun.com\/performance\/reference\/whitepapers\/tuning.html#section4.2.5\">Java Tuning White Paper<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Intro JVM * myfile.java &#8212; Compiler (javac) &#8211;> Byte code &#8212; java.exe &#8211;> JVM &#8212; OS &#8211;> Native code GC Sun JVM is generational and divides heap into * Young Generation &#8211; Eden Space &#8211; Survivor Space 0 (aka From &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=1198\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[14],"tags":[],"class_list":["post-1198","post","type-post","status-publish","format-standard","hentry","category-java"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s8cRUO-jvm","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1198"}],"version-history":[{"count":9,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1198\/revisions"}],"predecessor-version":[{"id":2906,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1198\/revisions\/2906"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}