Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Wednesday, July 18, 2007

Heap size limitation on Windows

For 32 bit Windows systems, the OS support 2GB address space. However, the maximum leap size that a JVM can allocate is less than 2GB. This is caused by the way the JDK DLLs are rebased.

For JDK1.3, the heap size is around 1.2GB. Here is a dump of the DLL layout for JDK1.3.0 using listdlls.exe

Base Size Path
0x00400000 0x5000 d:\jdk1.3\bin\java.exe
0x503f0000 0x10b000 d:\jdk1.3\jre\bin\hotspot\jvm.dll
0x50220000 0x7000 d:\jdk1.3\jre\bin\hpi.dll
0x50380000 0xd000 d:\jdk1.3\jre\bin\verify.dll
0x50250000 0x17000 d:\jdk1.3\jre\bin\java.dll
0x50390000 0xd000 d:\jdk1.3\jre\bin\zip.dll
0x6bd00000 0x21000 C:\WINNT\System32\cwbaudll.dll
0x77f60000 0x5e000 C:\WINNT\System32\ntdll.dll
0x77dc0000 0x3f000 C:\WINNT\system32\ADVAPI32.dll
0x77f00000 0x5e000 C:\WINNT\system32\KERNEL32.dll
0x77e70000 0x54000 C:\WINNT\system32\USER32.dll
0x77ed0000 0x2c000 C:\WINNT\system32\GDI32.dll
0x77e10000 0x57000 C:\WINNT\system32\RPCRT4.dll
0x78000000 0x40000 C:\WINNT\system32\MSVCRT.dll
0x77fd0000 0x2a000 C:\WINNT\System32\WINMM.dll


So that leaves 0x50000000 - 0x00400000 = 1276MB contiguous address space. Run the following command:
rebase.exe -b 0x6D000000 \jdk1.3\jre\bin\*.dll \jdk1.3\jre\bin\hotspot\jvm.dll

It will increase the heap size to around 1.65GB.

Compare that to the listdlls output for jdk1.5, which allows around 1.45GB heap size (with JDK1.4.2, -Xmx1200M is the maximum)
0x00400000 0xc000 5.00.0040.0005 D:\jdk1.5\bin\java.exe
0x6d6b0000 0x189000 5.00.0040.0005 D:\jdk1.5\jre\bin\client\jvm.dll
0x6d2f0000 0x8000 5.00.0040.0005 D:\jdk1.5\jre\bin\hpi.dll
0x6d680000 0xc000 5.00.0040.0005 D:\jdk1.5\jre\bin\verify.dll
0x6d370000 0x1d000 5.00.0040.0005 D:\jdk1.5\jre\bin\java.dll
0x6d6a0000 0xf000 5.00.0040.0005 D:\jdk1.5\jre\bin\zip.dll


rebase.exe is from Visual Studio.
listdlls.exe is from http://www.microsoft.com/technet/sysinternals/default.mspx.

Thursday, July 12, 2007

java.lang.OutOfMemoryError

Problem: when running Together Architect to audit a large code base, it reported java.lang.OutOfMemoryError

Solution: add java options when launching Together Architect.
-Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxPermSize=256M