Максимальный размер "кучи" Java 32-разрядной JVM на 64-разрядной ОС

Около #define частная общественность Вы можете также #define частный защищенный и затем определять некоторый класс нечто как потомка требуемого класса для имения доступа к, он (теперь защищен) методы через преобразование типа.

104
задан Community 23 May 2017 в 10:30
поделиться

7 ответов

32-битные JVM, которые рассчитывают иметь один большой кусок памяти и используют необработанные указатели, не могут использовать более 4 ГБ (поскольку это 32-битный предел, который также применяется к указателям). Это включает в себя Sun и - я почти уверен - также реализации IBM. Я не знаю, есть ли у JRockit или других большой объем памяти с их 32-разрядными реализациями.

Если вы ожидаете, что достигнете этого предела, вам следует серьезно подумать о запуске параллельного трека для проверки 64-битной JVM для вашей производственной среды. так что у вас есть все наготове, когда 32-битная среда выйдет из строя. В противном случае вам придется выполнять эту работу под давлением, что никогда не бывает хорошо.


Edit 2014-05-15: Oracle FAQ:

Максимальный теоретический предел кучи для 32-разрядной JVM составляет 4G. Из-за различных дополнительных ограничений, таких как доступный своп, использование адресного пространства ядра, фрагментация памяти и накладные расходы ВМ, на практике предел может быть намного ниже. В большинстве современных 32-разрядных систем Windows максимальный размер кучи составляет от 1,4 ГБ до 1,6 ГБ. В 32-разрядных ядрах Solaris адресное пространство ограничено 2 ГБ. В 64-разрядных операционных системах с 32-разрядной виртуальной машиной максимальный размер кучи может быть больше, приближаясь к 4G во многих системах Solaris.

( http://www.oracle.com/technetwork/java/hotspotfaq -138619.html # gc_heap_32bit )

66
ответ дан 24 November 2019 в 04:08
поделиться

You don't specify which OS.

Under Windows (for my application - a long running risk management application) we observed that we could go no further than 1280MB on Windows 32bit. I doubt that running a 32bit JVM under 64bit would make any difference.

We ported the app to Linux and we are running a 32bit JVM on 64bit hardware and have had a 2.2GB VM running pretty easily.

The biggest problem you may have is GC depending on what you are using memory for.

16
ответ дан 24 November 2019 в 04:08
поделиться

The limitations of a 32-bit JVM on a 64-bit OS will be exactly the same as the limitations of a 32-bit JVM on a 32-bit OS. After all, the 32-bit JVM will be running In a 32-bit virtual machine (in the virtualization sense) so it won't know that it's running on a 64-bit OS/machine.

The one advantage to running a 32-bit JVM on a 64-bit OS versus a 32-bit OS is that you can have more physical memory, and therefore will encounter swapping/paging less frequently. This advantage is only really fully realized when you have multiple processes, however.

9
ответ дан 24 November 2019 в 04:08
поделиться

Should be a lot better

For a 32-bit JVM running on a 64-bit host, I imagine what's left over for the heap will be whatever unfragmented virtual space is available after the JVM, it's own DLL's, and any OS 32-bit compatibility stuff has been loaded. As a wild guess I would think 3GB should be possible, but how much better that is depends on how well you are doing in 32-bit-host-land.

Also, even if you could make a giant 3GB heap, you might not want to, as this will cause GC pauses to become potentially troublesome. Some people just run more JVM's to use the extra memory rather than one giant one. I imagine they are tuning the JVM's right now to work better with giant heaps.

It's a little hard to know exactly how much better you can do. I guess your 32-bit situation can be easily determined by experiment. It's certainly hard to predict abstractly, as a lot of things factor into it, particularly because the virtual space available on 32-bit hosts is rather constrained.. The heap does need to exist in contiguous virtual memory, so fragmentation of the address space for dll's and internal use of the address space by the OS kernel will determine the range of possible allocations.

The OS will be using some of the address space for mapping HW devices and it's own dynamic allocations. While this memory is not mapped into the java process address space, the OS kernel can't access it and your address space at the same time, so it will limit the size of any program's virtual space.

Loading DLL's depends on the implementation and the release of the JVM. Loading the OS kernel depends on a huge number of things, the release, the HW, how many things it has mapped so far since the last reboot, who knows...

In summary

I bet you get 1-2 GB in 32-bit-land, and about 3 in 64-bit, so an overall improvement of about 2x.

3
ответ дан 24 November 2019 в 04:08
поделиться

Я попытался установить размер кучи до 2200 МБ на 32-битной машине Linux, и JVM работала нормально. JVM не запускалась, когда я установил ее на 2300M.

0
ответ дан 24 November 2019 в 04:08
поделиться

В Solaris ограничение составляет около 3,5 ГБ, начиная с версии Solaris 2.5. (около 10 лет назад)

2
ответ дан 24 November 2019 в 04:08
поделиться

Из 4.1.2 Размер кучи :

«Для 32-битной модели процесса максимальный размер виртуального адреса процесс обычно составляет 4 ГБ, хотя некоторые операционные системы ограничивают его 2 ГБ или 3 ГБ. Максимальный размер кучи обычно составляет -Xmx3800 м (1600 м) для 2 ГБ), хотя фактическое ограничение зависит от приложения. Для 64-битных моделей процессов максимум практически неограничен ».

Здесь есть довольно хороший ответ: Максимальный объем памяти Java в Windows XP .

14
ответ дан 24 November 2019 в 04:08
поделиться
Другие вопросы по тегам:

Похожие вопросы: