<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2888604325029355911</id><updated>2011-04-21T11:04:08.591-07:00</updated><title type='text'>...</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://googleismygod.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2888604325029355911/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://googleismygod.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Deepak</name><uri>http://www.blogger.com/profile/06533184348523346878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2888604325029355911.post-1174746907401673353</id><published>2008-10-21T23:30:00.000-07:00</published><updated>2008-10-24T11:26:58.837-07:00</updated><title type='text'>Tweaks to get maximum Heap size with Sun JDK (Windows)</title><content type='html'>&lt;div&gt;- Does your Java process using Sun JRE fails with -Xmx1200m on Windows 32-bit OS but you want more ? Here is some explaination on why it happens and how to fix it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;32-bit Windows by-default provides 2 GB of Virtual Address Space for each process; this is independent of the physical RAM in the system. When a process starts executing it loads process binary and other resources like DLLs at different addresses within the 2 GB Virtual Address Space.&lt;/div&gt;&lt;div&gt;Sun JVM Heap requires that a contiguous block of Virtual Address space be reserved (I guess it is for some GC optimizations) and the size of this contiguous block depends on other resources loaded by the JVM.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Following screen-shot of Process Explorer for a simple Java process helps in explaining this concept better. A Java process is run with following command-line&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;  &lt;span class="Apple-style-span" style="font-style: italic;"&gt;java -Xshare:on -Xmx500m MemTest&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_0S1PIAvkE-I/SP7Jdp4AsDI/AAAAAAAAAj4/vvh9MbmbVu8/s1600-h/Java-proc.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_0S1PIAvkE-I/SP7Jdp4AsDI/AAAAAAAAAj4/vvh9MbmbVu8/s400/Java-proc.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5259862926109487154" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Now we search for big contiguous chunks of memory and find two of them between&lt;/div&gt;&lt;div&gt; a) java.exe(0x400000) and classes.jsa (0x2AB80000) = 679 MB&lt;/div&gt;&lt;div&gt; b) classes.jsa(0x2C03B000) and lpk.dll(0x629C0000) = 873 MB&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;From these figures we see that if sharing mode is ON, it bisects the contiguous memory, greatly reducing the max heap size. If I modify the command-line to use -Xmx900m, the process will fail to start. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;DLLs should also be watched out for such issues. From my experience some of the DLLs from older service packs from Microsoft would load around 0x4000000, which reduced the max heap size possible.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lastly, if your Java application is deployed at customer-site, then some apps like anti-virus, etc tend to inject their DLLs in every running process. They can also cause such issue.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What to do for fixing this up&lt;/div&gt;&lt;div&gt;a) use -Xshare:off (sharing can be ON by default, so add this explicitly)&lt;/div&gt;&lt;div&gt;b) if some DLL is loading after 0x400000 but before 0x6000000, find a work-around for it (some missing hotfix, rebase DLL, etc)&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;External Resources:&lt;/div&gt;&lt;div&gt; - &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4358809"&gt;Bug raised at Sun on this&lt;/a&gt;&lt;/div&gt;&lt;div&gt; - &lt;a href="http://docs.sun.com/app/docs/doc/819-3681/abeia?a=view"&gt;Rebasing DLLs&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2888604325029355911-1174746907401673353?l=googleismygod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://googleismygod.blogspot.com/feeds/1174746907401673353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2888604325029355911&amp;postID=1174746907401673353' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2888604325029355911/posts/default/1174746907401673353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2888604325029355911/posts/default/1174746907401673353'/><link rel='alternate' type='text/html' href='http://googleismygod.blogspot.com/2008/10/tweaks-to-get-maximum-heap-size-with.html' title='Tweaks to get maximum Heap size with Sun JDK (Windows)'/><author><name>Deepak</name><uri>http://www.blogger.com/profile/06533184348523346878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_0S1PIAvkE-I/SP7Jdp4AsDI/AAAAAAAAAj4/vvh9MbmbVu8/s72-c/Java-proc.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2888604325029355911.post-1618519415569727594</id><published>2008-10-18T00:01:00.000-07:00</published><updated>2008-10-18T02:04:17.093-07:00</updated><title type='text'>JVM thread dump: simple yet effective Profiler</title><content type='html'>&lt;div style="text-align: justify;"&gt;Most people working with Java would already know uses of Thread-Dump for&lt;br /&gt;&lt;/div&gt; a) debugging deadlocks or&lt;br /&gt;b) see if a thread is still alive&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;There is another important use which i was reminded by my colleague yesterday while we were debugging a performance issue at a customer deployment. We had a theory based on logs that a particular piece of code is making the processing slow but we were still not able to pin-point the real cause. We wanted to try it in-house using Yourkit profiler but that would have taken few hours to reproduce the customer issue. At that point my colleague reminded that few Thread-Dumps taken 10-15 seconds apart can tell which part of code was consuming lot of time because there was high probability that this code would be found running in majority of these Thread-Dumps.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Luckily, we had also asked for a Thread-Dump from customer along with logs and within 2 minutes the root-cause of slow processing was found using that Thread-Dump. The slow processing was due to extra database hits from a feature which was excessively used and it wasn't optimized for such purpose.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;There are various ways to generate thread-dump, some of them are OS specific or have some constraints. For web application, the most useful way I find is to embed a JSP which can be invoked from the browser. For enterprise application, this helps customer to invoke it easily and send along with logs for debugging purpose. Code for the JSP I use is available &lt;a href="http://snippets.dzone.com/posts/show/6279"&gt;here&lt;/a&gt;. (Note: This JSP doesn't display the lock information which is available by other means of generating Thread-dump).&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;External Resources:&lt;/div&gt;&lt;div style="text-align: justify;"&gt; a) &lt;a href="http://snippets.dzone.com/posts/show/6279"&gt;JSP to generate Thread-dump&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2888604325029355911-1618519415569727594?l=googleismygod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://googleismygod.blogspot.com/feeds/1618519415569727594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2888604325029355911&amp;postID=1618519415569727594' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2888604325029355911/posts/default/1618519415569727594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2888604325029355911/posts/default/1618519415569727594'/><link rel='alternate' type='text/html' href='http://googleismygod.blogspot.com/2008/10/jvm-thread-dump-simple-yet-effective.html' title='JVM thread dump: simple yet effective Profiler'/><author><name>Deepak</name><uri>http://www.blogger.com/profile/06533184348523346878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
