Java maximum memory on Windows XP

前端 未结 13 1753
轻奢々
轻奢々 2020-11-22 09:27

I\'ve always been able to allocate 1400 megabytes for Java SE running on 32-bit Windows XP (Java 1.4, 1.5 and 1.6).

java -Xmx1400m ...

Toda

相关标签:
13条回答
  • 2020-11-22 09:35

    I got this error message when running a java program from a (limited memory) virtuozzo VPS. I had not specified any memory arguments, and found I had to explicitly set a small amount as the default must have been too high. E.g. -Xmx32m (obviously needs to be tuned depending on the program you run).

    Just putting this here in case anyone else gets the above error message without specifying a large amount of memory like the questioner did.

    0 讨论(0)
  • 2020-11-22 09:42

    I think it has more to do with how Windows is configured as hinted by this response: Java -Xmx Option

    Some more testing: I was able to allocate 1300MB on an old Windows XP machine with only 768MB physical RAM (plus virtual memory). On my 2GB RAM machine I can only get 1220MB. On various other corporate machines (with older Windows XP) I was able to get 1400MB. The machine with a 1220MB limit is pretty new (just purchased from Dell), so maybe it has newer (and more bloated) Windows and DLLs (it's running Window XP Pro Version 2002 SP2).

    0 讨论(0)
  • 2020-11-22 09:44

    Oracle JRockit, which can handle a non-contiguous heap, can have a Java heap size of 2.85 GB on Windows 2003/XP with the /3GB switch. It seems that fragmentation can have quite an impact on how large a Java heap can be.

    0 讨论(0)
  • 2020-11-22 09:44

    The JVM needs contiguous memory and depending on what else is running, what was running before, and how windows has managed memory you may be able to get up to 1.4GB of contiguous memory. I think 64bit Windows will allow larger heaps.

    0 讨论(0)
  • 2020-11-22 09:49

    Everyone seems to be answering about contiguous memory, but have neglected to acknowledge a more pressing issue.

    Even with 100% contiguous memory allocation, you can't have a 2 GiB heap size on a 32-bit Windows OS (*by default). This is because 32-bit Windows processes cannot address more than 2 GiB of space.

    The Java process will contain perm gen (pre Java 8), stack size per thread, JVM / library overhead (which pretty much increases with each build) all in addition to the heap.

    Furthermore, JVM flags and their default values change between versions. Just run the following and you'll get some idea:

     java -XX:+PrintFlagsFinal
    

    Lots of the options affect memory division in and out of the heap. Leaving you with more or less of that 2 GiB to play with...

    To reuse portions of this answer of mine (about Tomcat, but applies to any Java process):

    The Windows OS limits the memory allocation of a 32-bit process to 2 GiB in total (by default).

    [You will only be able] to allocate around 1.5 GiB heap space because there is also other memory allocated to the process (the JVM / library overhead, perm gen space etc.).

    Why does 32-bit Windows impose a 2 GB process address space limit, but 64-bit Windows impose a 4GB limit?

    Other modern operating systems [cough Linux] allow 32-bit processes to use all (or most) of the 4 GiB addressable space.

    That said, 64-bit Windows OS's can be configured to increase the limit of 32-bit processes to 4 GiB (3 GiB on 32-bit):

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa366778(v=vs.85).aspx

    0 讨论(0)
  • 2020-11-22 09:50

    Sun's JVM needs contiguous memory. So the maximal amount of available memory is dictated by memory fragmentation. Especially driver's dlls tend to fragment the memory, when loading into some predefined base address. So your hardware and its drivers determine how much memory you can get.

    Two sources for this with statements from Sun engineers: forum blog

    Maybe another JVM? Have you tried Harmony? I think they planned to allow non-continuous memory.

    0 讨论(0)
提交回复
热议问题