<?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; Work</title>
	<atom:link href="http://blog.codexp.net/category/work/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>MySQL Connector/J lockup</title>
		<link>http://blog.codexp.net/2008/11/30/mysql-connectorj-lockup/</link>
		<comments>http://blog.codexp.net/2008/11/30/mysql-connectorj-lockup/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 15:34:37 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.codexp.net/?p=24</guid>
		<description><![CDATA[Lately I have been working on a multi-threaded Java application that utilizes MySQL Connector/J 5.1.7
This is probably the easiest way to access a MySQL database from Java. Everything seemed to be fine until i recently ran a few days long test of the daemon application on one of our test servers. It did not like [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I have been working on a multi-threaded Java application that utilizes MySQL Connector/J 5.1.7</p>
<p>This is probably the easiest way to access a MySQL database from Java. Everything seemed to be fine until i recently ran a few days long test of the daemon application on one of our test servers. It did not like me in the long run, i am still not sure why and whether it really was a Conenctor/J problem or not.</p>
<p>In any case, the problem i have faced was CPU usage suddenly started raising to about 50% (in a period of one day) and it wasnt a spike &#8211; it was a steady raise. When i checked the log file there were no warnings except one i got a at the end of the day: MySQL connection link failure.</p>
<p>Now one may wonder &#8211; how is this related to MySQL Connector. Well, it seems to me that it was due to Statement cancellation timer lockup that it started causing problems. Right now i have modified the code of the application to cancel all statemnts explicitly as well as some forced Garbage Collection, just to make sure that nothing unwanted slips by. The new test has been deployed to the servers and we are about to see if it has any effect.</p>
<p>Another note about Java (not really MySQL related):<br />
It seems to be smart using &#8220;-server&#8221; option when starting a VM if the application is supposed to run for a very long time. The performance optimization is huge: we are talking about almost 2x performance optimization compared to &#8220;-client&#8221; VM (default).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codexp.net/2008/11/30/mysql-connectorj-lockup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java ain&#8217;t that bad</title>
		<link>http://blog.codexp.net/2008/11/29/java-aint-that-bad/</link>
		<comments>http://blog.codexp.net/2008/11/29/java-aint-that-bad/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 18:48:19 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.codexp.net/?p=18</guid>
		<description><![CDATA[Yeah, i never actually thought i would say this, but Java is not all that bad.
There are some bad things about it &#8211; but there are even some good ones, and in all honesty &#8212; that makes it up for me.
Now you might wonder &#8211; what&#8217;s so good about that slow, old language? Well, it [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, i never actually thought i would say this, but Java is not all that bad.</p>
<p>There are some bad things about it &#8211; but there are even some good ones, and in all honesty &#8212; that makes it up for me.</p>
<p>Now you might wonder &#8211; what&#8217;s so good about that slow, old language? Well, it is widely spread and there are tons of different open-source classes available which makes your life easier. Then there is type-hinting in Java makes it really hard to mess up with wrong data types comming in. And it IS suited for enterprise development.</p>
<p>I have been working with Java for quite some time now, and thou i still dont like it for pure web-app development (probably because i still didnt get a hang of Templating in JSP) it is damn nice and i like it more and more.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codexp.net/2008/11/29/java-aint-that-bad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
