<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The world of "Kube" &#187; Debugging</title>
	<atom:link href="http://blog.codexp.net/tag/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codexp.net</link>
	<description></description>
	<lastBuildDate>Wed, 17 Dec 2008 06:44:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>First step in Java application optimization</title>
		<link>http://blog.codexp.net/2008/12/01/first-step-in-java-application-optimization/</link>
		<comments>http://blog.codexp.net/2008/12/01/first-step-in-java-application-optimization/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 07:59:26 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://blog.codexp.net/?p=35</guid>
		<description><![CDATA[We are always trying to optimize our applications, make them run faster, use less resources, be more stable. Unfortunately this part of the development process is often left as a finishing part and sometimes is completely skipped.
And yet it is so simple to do those improvements while developing applications. One of them is not to [...]]]></description>
			<content:encoded><![CDATA[<p>We are always trying to optimize our applications, make them run faster, use less resources, be more stable. Unfortunately this part of the development process is often left as a finishing part and sometimes is completely skipped.</p>
<p>And yet it is so simple to do those improvements while developing applications. One of them is not to use <code>import package.*;</code> and only include the packages you really need. This may sound so simple but I doubt many people think about this when developing applications. I have often heard (and yes i have done that mistake myself recently) people say stuff like &#8220;I cant be bothered with every single include, i rather just include everything&#8221; and &#8220;It doesnt really matter&#8221;.</p>
<p>And to be all honest &#8211; it is true when developing small applicationsm that do not require to be run for a very long time without destroying the VM (a.k.a restarting the application). But in the long run &#8211; the more classes you are importing, the more PermGen memory is used &#8212; and that is a waste when you do not need so many classes.</p>
<p>So here is a first and really basic optimization suggestion:</p>
<p>Try avoiding importing * packages as much as possible. I do realize that it may not always be easy to do and your code may become a few hundered lines larger &#8212; but in the long run you will not regret it!</p>
<p>Now a fast numbers to prove my point</p>
<p>Unoptimized application PermGen usage:<strong>14.5Mb</strong> With the following * imports:</p>
<blockquote><p>import java.util.*;<br />
import java.io.*;<br />
import java.sql.*;</p></blockquote>
<p>Optimized application PermGen usage: <strong>10.2Mb</strong> When replaced * imports with in somewhat 30 classes:</p>
<blockquote><p>import java.io.File;<br />
import java.io.FileNotFoundException;<br />
import java.io.FileWriter;<br />
import java.io.IOException;<br />
import java.sql.Connection;<br />
import java.sql.DriverManager;<br />
import java.sql.PreparedStatement;<br />
import java.sql.ResultSet;<br />
import java.sql.SQLException;<br />
import java.sql.Timestamp;<br />
import java.util.Date;<br />
import java.util.Iterator;<br />
import java.util.Vector;</p></blockquote>
<p>As you can see numbers speak for themselves &#8211; that is quite an optimization</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codexp.net/2008/12/01/first-step-in-java-application-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring Remote Java Apps</title>
		<link>http://blog.codexp.net/2008/11/30/monitoring-remote-java-apps/</link>
		<comments>http://blog.codexp.net/2008/11/30/monitoring-remote-java-apps/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 18:38:49 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.codexp.net/?p=33</guid>
		<description><![CDATA[Monitoring remote Java applications may not be a very easy task. Especially considering the application needed to be started with -Dcom.sun.management.jmxremote option to allow jConsole access it.
VisualVM has made it a bit easier for us to monitor remote apps. You will have to start jstatd process on your remote system and then you can monitor [...]]]></description>
			<content:encoded><![CDATA[<p>Monitoring remote Java applications may not be a very easy task. Especially considering the application needed to be started with <code>-Dcom.sun.management.jmxremote</code> option to allow jConsole access it.</p>
<p>VisualVM has made it a bit easier for us to monitor remote apps. You will have to start <em>jstatd </em>process on your remote system and then you can monitor how your remote VM is feeling.</p>
<p>However.. there are some pitfalls. Here are 2 of the most annoying once:</p>
<p><strong>When starting jstatd you are getting Security Exceptions</strong></p>
<p>To solve this error you will need to create a policy file containing something like this (call it jstatd.all.policy):</p>
<blockquote>
<pre>grant codebase "file:${java.home}/../lib/tools.jar" {

permission java.security.AllPermission;

};</pre>
</blockquote>
<p>Now start <em>jstatd </em>with the following command:</p>
<blockquote>
<pre>jstatd -J-Djava.security.policy=jstatd.all.policy</pre>
</blockquote>
<p><strong>You are trying to connect to the remote host but getting Socket connection refused.</strong></p>
<p>This is most likely caused because of an underlying exception &#8211; connection refused to host 127.0.0.1 or something simmilar (not the IP you are trying to access). This is easily solved by adding the following parameter to <em>jstatd </em>startup command:</p>
<blockquote>
<pre>-J-Djava.rmi.server.hostname=&lt;your ip or hostname&gt;</pre>
</blockquote>
<p>&#8230; Naturally there are more pitfalls but I am not going to cover all of them here. VirtualVM, just like legacy jConsole may be very usefull for monitoring how some applications act in the testing environment before you put them into producstion. Usually things that do not appear on your development machine while profiling may appear in the test environment where it is hard to notice them without profiling.</p>
<p>One of such problems may be MySQL Connector/J PermGen leak caused by Statement cancelation timer (something i have encountered recently and trying to come around)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codexp.net/2008/11/30/monitoring-remote-java-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
