kivy / pyjnius

Access Java classes from Python
https://pyjnius.readthedocs.org
MIT License
1.4k stars 255 forks source link

Windows 7 64-bit: Error occurred during initialization of VM #99

Open yassam opened 10 years ago

yassam commented 10 years ago

I managed to install jnius on Windows 7 (I had to use MinGW to build it - I got compiler errors using Visual C++) but when I try to "import jnius" at the python prompt I get the following:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Segmentation fault

I tried logging out and back in (as suggested elsewhere) but it made no difference.

I have 64-bit Windows 7, but I'm using 32-bit Python and JDK.

Python version 2.7.6.

I have 8GB of RAM.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/2026641-windows-7-64-bit-error-occurred-during-initialization-of-vm?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github).
bevanj commented 10 years ago

I have gotten the same error message with identical specs to those listed above except 12GB of RAM.

evbo commented 10 years ago

Interestingly, when I had only 3 GB of RAM this issue NEVER occurred. Today, immediately after upgrading to 8 GB, this started happening!

Even doing from jnius import autoclass causes this issue just as import jnius does.

Note: This post hints at this problem also and provides a workaround: https://github.com/kivy/pyjnius/issues/65

Logging out and logging back in temporarily does in fact temporarily fix the problem in some cases.

I have:

Windows 7 64 Bit 32-bit Python 2.7.6 32-bit 7.55 JDK I installed jnius through sikuli_cpython - https://github.com/kevlened/sikuli_cpython

evbo commented 10 years ago

Also, note this fork: https://github.com/kivy/pyjnius/pull/110

It provides a means of limiting the VM heap size before you import jnius. After installing from this fork: https://github.com/abrasive/pyjnius (using the usual python setup.py install), usage looks like this:

import jnius_config
jnius_config.add_options('-Xmx512m') # or something reasonable for your application
# import jnius like you did before...
from jnius import autoclass
chunyisong commented 8 years ago

my os: Windows 10 64 Bit 32-bit Python 2.7.11 32-bit jdk1.8.0_73 The error occurs when the jvm.dll path is server Xmx < 600M;But it works when jvm.dll path under client;