0
Error occurred during initialization of VM.
Could not reserve enough space for object heap.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

The bat file has the following command:

java -cp stanford-corenlp-3.2.0.jar;stanford-corenlp-3.2.0-models.jar;xom.jar;joda-time.jar;jollyday.jar -Xmx3g edu.stanford.nlp.pipeline.StanfordCoreNLP -props props.properties -filelist filelist.txt

It works from the cmd window with no errors!

I have the following python code:

import os
import subprocess

os.chdir('C:/Users/Christos/Documents/stanford-corenlp-full-2013-06-20/')

p = subprocess.Popen(r'start cmd /c run_mouskos.bat', shell=True)

p.wait()

print 'done'

I have also tried various other ways for executing the bat file from python with no luck. How can i run it with no errors?

LostAvatar
  • 795
  • 7
  • 20
user2120596
  • 35
  • 1
  • 4

2 Answers2

1

I've recently had this issue. I'm running a Django application, which is served by uWSGI. I'm actually running uWSGI processes with as-limit argument set to 512MB. After digging around this, I've discovered that every process which the application runs using subprocess, will keep same OS limits as uWSGI processes.

After increasing the value of as-limit to 1GB, i was not able to reproduce this issue.

Maybe this could help you

0

Try setting the heap size explicitly: see Could not reserve enough space for object heap

This setting can be also be affected by environment variables - you should print the variables in the batch file (I think the set command on Windows does this). This would allow you to see if the variables are the same in the two cases you've tried.

Of course, you'll need to capture the output from the batch script (or make it otherwise visible) in order to perform the comparison.

Community
  • 1
  • 1
mpenkov
  • 21,621
  • 10
  • 84
  • 126
  • I have put the following code in the bat file 'set "JAVA_OPTS=-Xms512m -Xmx512m -XX:MaxPermSize=256m' and still doesn't run. With the 'set' i checked both environment variables and they were the same except from the Python cmd that had python settings included and a django one: 'DJANGO_SETTINGS_MODULE=python_test.settings' where python_test is the project which the program is included. Is it running through Django server? – user2120596 Oct 15 '13 at 11:25
  • So you have this thing running inside a Web application? Or is it a stand-alone application? – mpenkov Oct 15 '13 at 14:09
  • 1
    It's a standalone application – user2120596 Oct 15 '13 at 15:12