Не удалось зарезервировать память, хотя есть место

855
lucasnadalutti

Я пытаюсь использовать Weka ( http://www.cs.waikato.ac.nz/ml/weka/ ) в 64-битной системе Windows 7, которая по своей природе очень ограничена в памяти. Проблема в том, что на моем ПК 8 ГБ ОЗУ, а диспетчер задач говорит, что выделено только 1,5. Тем не менее, когда я пытаюсь запустить Weka, который предположительно использует только 3 из этих ГБ, происходит сбой со следующей ошибкой:

Error occurred during initialization of VM Could not reserve enough space for 3072000KB object heap 

Идеи?

1
Вы используете 32- или 64-разрядную версию Windows 7? AFH 8 лет назад 0
32 бит, извините буду редактировать lucasnadalutti 8 лет назад 0
Это часть вашей проблемы: только 4 ГБ памяти доступно для адресации. AFH 8 лет назад 0
Извините, пришлось перепроверить, что на самом деле 64. Извините, мой плохой lucasnadalutti 8 лет назад 0
Сообщение об ошибке указывает на то, что для кучи объектов требуется 300 МБ. Откуда появилось ваше требование в 3 ГБ? AFH 8 лет назад 0
Я фактически пропустил 0, так как мне пришлось скопировать это вручную по причинам, которые не стоит объяснять. Отредактировал это тоже lucasnadalutti 8 лет назад 0
Мне интересно, может ли ваша установка Java быть 32-битной. Если это так, вы должны быть осторожны с объемом выделенной памяти, например, если вы выделите 6 ГБ, 32-разрядное приложение увидит только 2 ГБ. AFH 8 лет назад 0

1 ответ на вопрос

4
DavidPostill

Error occurred during initialization of VM

Could not reserve enough space for 3072000KB object heap

You need to increase the maximum heap size of the JVM.

Try:

java -Xmx4g ... 

Note:

  • You will also need to make sure you have a 64bit version of the JVM installed.

OutOfMemoryException

Most Java virtual machines only allocate a certain maximum amount of memory to run Java programs. Usually this is much less than the amount of RAM in your computer. However, you can extend the memory available for the virtual machine by setting appropriate options. With Sun's JDK, for example, you can use

java -Xmx512m ...

to set the maximum Java heap size to 512MB. You can use -Xmx2g to set it to 2GB.

For more information about these options, follow this link.

Note:

Do not use the -Xms parameter as well, as this will lead quickly to an OutOfMemoryException.

If you are using WEKA under Windows and start WEKA from the Start Menu, check out the Invocation section of the Java Virtual Machine article, it explains what files you have to edit in order to give WEKA more memory (RunWEKA.bat or RunWEKA.ini, depending on your version).

But please have in mind, that your hardware architecture and/or operating system will limit the amount of memory you can allocate (see the 32-bit and 64-bit sections of the Java Virtual Machine article).

Source OutOfMemoryException


Can I check how much memory is available for WEKA?

You can easily check, how much memory WEKA can use (this depends on the maximum heap size the Java Virtual Machine was started with).

  1. developer version
    • start the SimpleCLI
    • run the following command:
    • java weka.core.SystemInfo
    • the property memory.max lists the maximum amount of memory available to WEKA
  2. book version (and developer version)
    • start the Explorer
    • right-click in the log panel
    • select Memory information to output the information to the log

In case you should run into an OutOfMemoryException, you will have to increase the maximum heap size. How much you can allocate, depends heavily on the operating system and the underlying hardware (see sections 32-Bit and 64-Bit of the Java Virtual Machine article). Also, have a look at the OutOfMemoryException section further down.

Source Can I check how much memory is available for WEKA?


Further Reading

Большое спасибо за подробный ответ! lucasnadalutti 8 лет назад 0
Обратите внимание, что когда диспетчер задач говорит: «Мой компьютер имеет 8 ГБ ОЗУ, а менеджер задач говорит, что выделено только 1,5», это говорит о ** физической памяти ** - ОЗУ. Когда Java VM жалуется на распределение пространства, речь идет о ** виртуальной ** памяти. Конечно, вы можете использовать намного больше виртуальной памяти, чем у вас, но для того, чтобы не использовать весь ваш предел фиксации с заранее выделенной кучей, которую ваше конкретное Java-приложение может не использовать, Java VM имеет ограничение по умолчанию для того, как много это выделит. Jamie Hanrahan 8 лет назад 1

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