<?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:blogger='http://schemas.google.com/blogger/2008' 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-2336259008029476230</id><updated>2024-09-01T05:55:34.512-04:00</updated><title type='text'>Java and Software job - Real time experiences</title><subtitle type='html'>As a java software developer, we encounter very common issues in real time development and at production level. I have discussed the resolutions for these problems at this platform.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://job-experiences.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2336259008029476230/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://job-experiences.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Tapan</name><uri>http://www.blogger.com/profile/11915562783142930734</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2336259008029476230.post-4928123025617575560</id><published>2011-04-23T23:19:00.002-04:00</published><updated>2011-04-23T23:19:41.161-04:00</updated><title type='text'>OutOfMemoryError</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I recently encountered java.lang.OutOfMemoryError in an application   at production level. This makes the application totally unavailable to   the users. If the application is too critical, usually, we tend to   restart the application and make it available immediately to the users   and think of debugging it through previous logs.&lt;br /&gt;
In order to debug the issue in the right direction, we should try to complete the following before restarting the application -&lt;br /&gt;
&lt;br /&gt;
1. Get the heap histogram through &lt;i&gt;jmap&lt;/i&gt; (a java command line tool) as -&lt;br /&gt;
&amp;lt;JAVA_HOME&amp;gt;/bin/jmap   -histo:live &amp;lt;pid - application process id&amp;gt; &amp;gt; &amp;lt;filepath   where you want to save the snapshot&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Take the thread dump.&lt;br /&gt;
on unix -&lt;br /&gt;
&amp;gt; kill -3 &amp;lt;application pid&amp;gt;&lt;br /&gt;
The   above would produce the thread dump to the console (stdout) attached  to  the application. It would be there in your log file only if you are   redirecting stdout to your log file.&lt;br /&gt;
&lt;br /&gt;
3. Get the heap dump - &lt;br /&gt;
&lt;br /&gt;
If   you have HeapDumpOnOutOfMemoryError VM option enabled, then its great   and it will produce the dump in a file. You can also enable this option   while your application is running -&lt;br /&gt;
&lt;br /&gt;
&amp;lt;JAVA_HOME&amp;gt;/bin/jinfo -flag +HeapDumpOnOutMemoryError &amp;lt;pid&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Heap dump can also be obtained as - &lt;br /&gt;
&amp;lt;JAVA_HOME&amp;gt;/bin/jmap -dump:live,file=heap.out,format=b &amp;lt;pid&amp;gt; &lt;br /&gt;
&lt;br /&gt;
4. Run &lt;i&gt;top &lt;/i&gt;command (on unix) and save the snapshot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The   above are the minimal steps that we should perform before restarting   the application. This data collection would guide us in the right   direction while debugging the issue.&lt;br /&gt;
&lt;br /&gt;
The heap histogram   would tell us what the top objects are which acquire maximum heap   (usually we are interested in objects that belong to application   classes). We can try to relate the application behavior why these   objects are lying there in heap and not getting garbage collected.&lt;br /&gt;
&lt;br /&gt;
The heap dump can be analysed through &lt;i&gt;jhat&lt;/i&gt;   (though it needs lot of memory to start with). We can see the object   graph for the objects occupying most of the heap and can analyse their   lifecycle.&lt;br /&gt;
&lt;br /&gt;
The link below might be useful to understand analysing and monitoring the java application -&lt;br /&gt;
http://java.sun.com/developer/technicalArticles/J2SE/monitoring/&lt;br /&gt;
&lt;br /&gt;
Let me know about your thoughts and real-time experience with OutOfMemoryError.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe align=&quot;right&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=javaandsoftjo-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0321356683&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://job-experiences.blogspot.com/feeds/4928123025617575560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://job-experiences.blogspot.com/2011/04/outofmemoryerror.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2336259008029476230/posts/default/4928123025617575560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2336259008029476230/posts/default/4928123025617575560'/><link rel='alternate' type='text/html' href='http://job-experiences.blogspot.com/2011/04/outofmemoryerror.html' title='OutOfMemoryError'/><author><name>Tapan</name><uri>http://www.blogger.com/profile/11915562783142930734</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>