Re: Ranting about JVM's default memory limits...
Zig wrote:
On Sat, 02 Aug 2008 18:57:40 -0400, Arne Vajh?j <arne@vajhoej.dk> wrote:
See above for 2G not being accepted on my machine.
Many 32 bit OS including Windows split the total of 4 GB in system
space and process space.
Java can only use process space.
2 GB - "some stuff" is what is available.
I find this interesting: could you provide some further information on
this?
It is pretty simple.
Windows divide the 4 GB address space in 2 parts:
2 GB for processes
2 GB for system
The 2 GB process space is per process. The 2 GB system space is shared
among processes.
By using the /3GB switch you can change that from 2+2 til 3+1.
The "some stuff" is all the non Java stuff that a process has
mapped.
I had previously been under the impression that the 2 GB limit comes
into effect for applications that are likely to do signed comparisons on
pointers - such as needing to call a legacy routine which returns
sub-zero values when it needs to indicate an error and an error-code in
one result.
No. Signed/unsigned of pointers has nothing to do with that.
To make a process use more than 2 GB on Windows, the executable image
has to be compiled with the /LARGEADDRESSAWARE compiler option (assuming
MSVC) : http://msdn.microsoft.com/en-us/library/wz223b1z.aspx
That is an option that tells Windows that the EXE can use
more than 2 GB.
It is used for:
- 32 bit windows with /3GB where the app can get 3 GB
- 64 bit windows where a 32 bit app can get 4 GB
(because the system stuff is elsewhere)
If I examing the file headers for a JDK, here's
jdk1.6.0_06\jre\bin\server\jvm.dll
Dumper Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file jvm.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
14C machine (i386)
5 number of sections
47E8EFDF time date stamp Tue Mar 25 08:28:15 2008
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
210E characteristics
Executable
Line numbers stripped
Symbols stripped
32 bit word machine
DLL
And for jdk1.6.0_06\bin\javaw.exe
Dump of file javaw.exe
PE signature found
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
14C machine (i386)
4 number of sections
47E8C5CB time date stamp Tue Mar 25 05:28:43 2008
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
10F characteristics
Relocations stripped
Executable
Line numbers stripped
Symbols stripped
32 bit word machine
Had those images been compiled with /LARGEADDRESSAWARE, the
"characteristics" section will include the message:
Application can handle large (>2GB) addresses
Without that flag being set in the executable files, I believe the OS
limits the memory the process may request. In theory, you can use
"editbin" to manually set it - but flipping bits in compiled exe files
seems to be asking for trouble.
I am surprised that those flags aren't set when Sun does a java build -
it would be nice if they were.
It is not as simple as that.
Most JVM's requires that the heap is continuous.
Even with /3GB Windows puts something in at the 2 GB mark, so
that most JVM's can not use the 3 GB.
The only JVM I know that can use 3 GB is BEA's JRockit.
Arne