<?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; Optimization</title>
	<atom:link href="http://blog.codexp.net/tag/optimization/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>
	</channel>
</rss>
