<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Only getting 340 Megs of usable heap out of 2 Gigs in Java &#8211; why the limit?</title>
	<atom:link href="http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/feed" rel="self" type="application/rss+xml" />
	<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html</link>
	<description>Best practices for your goals</description>
	<lastBuildDate>Fri, 03 Sep 2010 00:32:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: bloid</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-267</link>
		<dc:creator>bloid</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-267</guid>
		<description>I run a process on a 64bit 4 core RHEL system which needs 11GB of ram (scanning the human and mouse genomes simultaneously) just by using the -Xmx11G flag, and runs fine on Java 5 and 6...  The machine does have 16GB of RAM installed, but it could be worth running a test on a later version of java to see if you get better results...

Odd...I&#039;ve never seen this behavior..
</description>
		<content:encoded><![CDATA[<p>I run a process on a 64bit 4 core RHEL system which needs 11GB of ram (scanning the human and mouse genomes simultaneously) just by using the -Xmx11G flag, and runs fine on Java 5 and 6&#8230;  The machine does have 16GB of RAM installed, but it could be worth running a test on a later version of java to see if you get better results&#8230;</p>
<p>Odd&#8230;I&#8217;ve never seen this behavior..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anjan Bacchu</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-268</link>
		<dc:creator>Anjan Bacchu</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-268</guid>
		<description>hi there,

I ran the following program on a win xp sp2 with 2 GB ram. I gave the VM 700 MB and asked it to allocate 670 MB and it was able to consistenly allocate that memory in 1 chunk. In your case, you are allocating multiple chunks of memory which has its memory managment overheads but I would think that it would not be as bad as you state.

I tested the program in 1.4, 1.5 and 1.6 of sun&#039;s jdk and all of them pretty much behave similarly.

here&#039;s the program.

import java.lang.Runtime;
import java.text.DecimalFormat;

public class Test {
public static void main(String [] args) {
//byte [] array = new byte[1024 * 1024 * 700];

if (args.length == 0) {
usage();
}

final int count = Integer.valueOf(args[0]);
System.out.println(&quot;alloc.value = &quot; + args[0]);

byte [] array = new byte[count];
System.out.println(&quot;jvm version &quot; + System.getProperties().getProperty(&quot;java.vm.version&quot;));
System.out.println(&quot;total memory = &quot; +
(new DecimalFormat(&quot;###,###,###.##&quot;)).format(Runtime.getRuntime().totalMemory())
+ &quot;\nfree memory = &quot; +
(new DecimalFormat(&quot;###,###,###.##&quot;)).format(Runtime.getRuntime().freeMemory()));
}

private static void fail(String msg) {
System.err.println(msg);
System.exit(-1);
}

private static void usage() {
fail(&quot;ERROR : USAGE Test &quot;);
}
}

</description>
		<content:encoded><![CDATA[<p>hi there,</p>
<p>I ran the following program on a win xp sp2 with 2 GB ram. I gave the VM 700 MB and asked it to allocate 670 MB and it was able to consistenly allocate that memory in 1 chunk. In your case, you are allocating multiple chunks of memory which has its memory managment overheads but I would think that it would not be as bad as you state.</p>
<p>I tested the program in 1.4, 1.5 and 1.6 of sun&#8217;s jdk and all of them pretty much behave similarly.</p>
<p>here&#8217;s the program.</p>
<p>import java.lang.Runtime;<br />
import java.text.DecimalFormat;</p>
<p>public class Test {<br />
public static void main(String [] args) {<br />
//byte [] array = new byte[1024 * 1024 * 700];</p>
<p>if (args.length == 0) {<br />
usage();<br />
}</p>
<p>final int count = Integer.valueOf(args[0]);<br />
System.out.println(&#8220;alloc.value = &#8221; + args[0]);</p>
<p>byte [] array = new byte[count];<br />
System.out.println(&#8220;jvm version &#8221; + System.getProperties().getProperty(&#8220;java.vm.version&#8221;));<br />
System.out.println(&#8220;total memory = &#8221; +<br />
(new DecimalFormat(&#8220;###,###,###.##&#8221;)).format(Runtime.getRuntime().totalMemory())<br />
+ &#8220;\nfree memory = &#8221; +<br />
(new DecimalFormat(&#8220;###,###,###.##&#8221;)).format(Runtime.getRuntime().freeMemory()));<br />
}</p>
<p>private static void fail(String msg) {<br />
System.err.println(msg);<br />
System.exit(-1);<br />
}</p>
<p>private static void usage() {<br />
fail(&#8220;ERROR : USAGE Test &#8220;);<br />
}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hung Huynh</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-269</link>
		<dc:creator>Hung Huynh</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-269</guid>
		<description>You might want to take a look at Terracotta (http://www.terracotta.org) . It allows you to have virtually unlimited heap size (spilling to disk as needed)
</description>
		<content:encoded><![CDATA[<p>You might want to take a look at Terracotta (<a href="http://www.terracotta.org" rel="nofollow">http://www.terracotta.org</a>) . It allows you to have virtually unlimited heap size (spilling to disk as needed)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: messi</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-270</link>
		<dc:creator>messi</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-270</guid>
		<description>http://developers.sun.com/mobility/midp/articles/garbagecollection2/#3
</description>
		<content:encoded><![CDATA[<p><a href="http://developers.sun.com/mobility/midp/articles/garbagecollection2/#3" rel="nofollow">http://developers.sun.com/mobility/midp/articles/garbagecollection2/#3</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Malter</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-271</link>
		<dc:creator>Adam Malter</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-271</guid>
		<description>The problem you are running into is memory fragmentation in the JVM. Arrays need &#039;contiguous&#039; memory for allocation. On our 32 bit Windows machines, this comes out to around 300-400megs, just as you saw. This number decreases as you run and the heap becomes more and more fragmented.

Our solution was to create a ChunkedByteBuffer that allocates data in 64k chunks and throws an interface in front that decorates it as a standard list. Using the chunked methodology we are able allocate 1.2gigs of the 1.4gig available on the heap.

For now the code is buried in our commercial project, but I&#039;ll chat with our project lead if there is any interest in it.
</description>
		<content:encoded><![CDATA[<p>The problem you are running into is memory fragmentation in the JVM. Arrays need &#8216;contiguous&#8217; memory for allocation. On our 32 bit Windows machines, this comes out to around 300-400megs, just as you saw. This number decreases as you run and the heap becomes more and more fragmented.</p>
<p>Our solution was to create a ChunkedByteBuffer that allocates data in 64k chunks and throws an interface in front that decorates it as a standard list. Using the chunked methodology we are able allocate 1.2gigs of the 1.4gig available on the heap.</p>
<p>For now the code is buried in our commercial project, but I&#8217;ll chat with our project lead if there is any interest in it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henrik S</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-272</link>
		<dc:creator>Henrik S</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-272</guid>
		<description>The Sun JVM requires a contiguous memory space for the heap, this can limit the heap size if you some shared library gets loaded into the address space. BEA JRockit does not have this problem, see:
http://dev2dev.bea.com/blog/hstahl/archive/2005/12/how_to_get_almo.html

A second issue is that each JVM will store some amount of metadata per object for GC, locks etc. This will steal away some heap space. The amount may vary with JVMs, so again you may want to try a different one.

The latest 1.4 version of JRockit can be downloaded here and it is free (as in beer):
http://commerce.bea.com/products/weblogicjrockit/jrockit_prod_fam.jsp

-- Henrik

</description>
		<content:encoded><![CDATA[<p>The Sun JVM requires a contiguous memory space for the heap, this can limit the heap size if you some shared library gets loaded into the address space. BEA JRockit does not have this problem, see:<br />
<a href="http://dev2dev.bea.com/blog/hstahl/archive/2005/12/how_to_get_almo.html" rel="nofollow">http://dev2dev.bea.com/blog/hstahl/archive/2005/12/how_to_get_almo.html</a></p>
<p>A second issue is that each JVM will store some amount of metadata per object for GC, locks etc. This will steal away some heap space. The amount may vary with JVMs, so again you may want to try a different one.</p>
<p>The latest 1.4 version of JRockit can be downloaded here and it is free (as in beer):<br />
<a href="http://commerce.bea.com/products/weblogicjrockit/jrockit_prod_fam.jsp" rel="nofollow">http://commerce.bea.com/products/weblogicjrockit/jrockit_prod_fam.jsp</a></p>
<p>&#8211; Henrik</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anjan Bacchu</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-273</link>
		<dc:creator>Anjan Bacchu</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-273</guid>
		<description>hi Adam Malter/all,

Nice to know about your technique. Can you post some code ? It will be nice to add it to your toolkit.

But, I was successfully able to allocate a single array of 670,000,000(670 MB) bytes when the JVM was given a -Xmx value of 700 MB. And I was using a Sun jdk 1.4.x, 1.5.x and 1.6x.

I can understand that if the heap gets badly defragmented over time, then I might NOT be able to allocate the above chunk.

Any idea why some of us are seeing limitations of 300-400 MB ?

Thanks,

BR,
~A
</description>
		<content:encoded><![CDATA[<p>hi Adam Malter/all,</p>
<p>Nice to know about your technique. Can you post some code ? It will be nice to add it to your toolkit.</p>
<p>But, I was successfully able to allocate a single array of 670,000,000(670 MB) bytes when the JVM was given a -Xmx value of 700 MB. And I was using a Sun jdk 1.4.x, 1.5.x and 1.6x.</p>
<p>I can understand that if the heap gets badly defragmented over time, then I might NOT be able to allocate the above chunk.</p>
<p>Any idea why some of us are seeing limitations of 300-400 MB ?</p>
<p>Thanks,</p>
<p>BR,<br />
~A</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anjan Bacchu</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-274</link>
		<dc:creator>Anjan Bacchu</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-274</guid>
		<description>hi there,

I further noticed that I could allocate upto 1425 MB for the JVM on my windows XP box. The java program itself could allocate 1350MB from the JVM.

I could not increase it beyond that on Windows, though. The ONLY way I know that could increase it beyond that would be to add the /3GB switch to the operating system boot.ini file which should let me allocate about 2.4 GB for the java process.

BR,
~A
</description>
		<content:encoded><![CDATA[<p>hi there,</p>
<p>I further noticed that I could allocate upto 1425 MB for the JVM on my windows XP box. The java program itself could allocate 1350MB from the JVM.</p>
<p>I could not increase it beyond that on Windows, though. The ONLY way I know that could increase it beyond that would be to add the /3GB switch to the operating system boot.ini file which should let me allocate about 2.4 GB for the java process.</p>
<p>BR,<br />
~A</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Infernoz</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-275</link>
		<dc:creator>Infernoz</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-275</guid>
		<description>Memory fragmentation should only rarely occur on a system with an MMU (all current x86 CPUs), the OS should remap the 4KB memory pages into a continuous block and the JVM should take advantage of this.  If not, then the OS and JVM designers need a serious kick up the backside!


</description>
		<content:encoded><![CDATA[<p>Memory fragmentation should only rarely occur on a system with an MMU (all current x86 CPUs), the OS should remap the 4KB memory pages into a continuous block and the JVM should take advantage of this.  If not, then the OS and JVM designers need a serious kick up the backside!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Levison</title>
		<link>http://agilepainrelief.com/notesfromatooluser/2007/07/only-getting-34.html/comment-page-1#comment-276</link>
		<dc:creator>Mark Levison</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://agilepainrelief.com/2007/07/only-getting-34/#comment-276</guid>
		<description>Infernoz - I made the same mistake at first. The problem is not the OS memory but Java&#039;s heap. Java will only hand memory in contiguous chunks which means if the Java heap is fragmented your request will not be granted. The obvious solution to this problem is to allocate your memory in smaller chunks perhaps 10-100,000 int/double chunks.
</description>
		<content:encoded><![CDATA[<p>Infernoz &#8211; I made the same mistake at first. The problem is not the OS memory but Java&#8217;s heap. Java will only hand memory in contiguous chunks which means if the Java heap is fragmented your request will not be granted. The obvious solution to this problem is to allocate your memory in smaller chunks perhaps 10-100,000 int/double chunks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
