heap memory used with MaxPermSize
843811Jan 8 2003 — edited Apr 2 2003In the article:
http://developer.java.sun.com/developer/community/chat/JavaLive/2001/jl0327.html
Tim Cramer described the JVM Heap memory used as:
<quote>
ming: Steve, if Perm Size is in a separate area, are we saying that there should be a formula like: MaxNewSize+MaxPermSize=max heap size?
TimCramer: For 1.3 here's the formula:
TotalHeapSize = -Xmx setting + MaxPermSize
The heap is further divided into Young and Old generation: -XX:MaxNewSize is
taken from the -Xmx setting, thus, -Xmx1024m -XX:NewSize=256m
-XX:MaxPermSize=32m yields a 1056m heap, with 768m in the old and 256 in the new generation.
</quote>
In testing this with 1.3.1_03, it does not seem accurate. I can vary MaxPermSize without affecting the amount of heap memory as described in the article. The article at URL: http://java.sun.com/docs/hotspot/gc/
seems more accurate.
Results from running a simple test with different settings:
-ms512m -mx512m -XX:MaxPermSize=64m VMMain 65536
Address Kbytes Resident Shared Private Permissions Mapped File
D6C00000 525312 271096 - 271096 read/write/exec [ anon ]
-------- ------ ------ ------ ------
total Kb 551968 292736 1552 291184
-Xms512m -Xmx512m -XX:MaxPermSize=128m VMMain 65536
Address Kbytes Resident Shared Private Permissions Mapped File
D2C00000 525312 271096 - 271096 read/write/exec [ anon ]
-------- ------ ------ ------ ------
total Kb 551992 292760 1544 291216
-Xms512m -Xmx512m -XX:MaxPermSize=256m VMMain 65536
Address Kbytes Resident Shared Private Permissions Mapped File
CAC00000 525312 271096 - 271096 read/write/exec [ anon ]
-------- ------ ------ ------ ------
total Kb 552040 292808 1544 291264
The code I slapped together to test this looks like:
public class VMMain
{
public static void main(String args[])
{
Object[] obj = null;
String arg0 = null;
int seed = 1024;
int counter = 0;
int cumulative = 0;
int size = 0;
StringBuffer prnt = new StringBuffer();
try {
System.gc();
if( 0 < args.length ) {
arg0 = args[ 0 ];
prnt.append( "\nCommand line arg[0] = " ).append( arg0 ).append( "\n" );
counter = new Integer( arg0 ).intValue();
prnt.append( "Create Object array of size:\n" );
for( int i = 1; i < counter; i=i*2 ) {
size = seed * i;
cumulative = cumulative + size;
prnt.append( size ).append( " with a cumulative size of " ).append( cumulative ).append( "\n" );
obj = new Object[ size ];
Thread.sleep( 100 );
}
}
System.out.println( "\nCheck pmap now on (pid):\nps -ef | grep java\npmap -x (pid) >> $HOME/vm_pmap.log\n" );
Thread.sleep( 30000 );
System.gc();
}
catch(Throwable t) {
prnt.append( "Caught exception " ).append( t.toString() );
}
System.out.println( prnt.toString() );
}
}