• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Init of VM error when calling java from PHP

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I don't know if this is a Java problem, PHP problem, or server problem, but I thought I would start here:

On server, I can ssh and run command 'java -version' and outputs version okay.

Run shell_exec in PHP script and I get this error:

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

Any ideas?

Server is running Debian squeeze
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you on a 32 bit VM or 64 bit and what are your memory settings?

Does it work if you start the java program with -mx256m or -mx512m?
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

E Armitage wrote:Are you on a 32 bit VM or 64 bit and what are your memory settings?

Does it work if you start the java program with -mx256m or -mx512m?



Thanks for replying,

64 bit, and no it doesn't

java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

E Armitage wrote:what are your memory settings?



I don't know how to find that - I am using shared hosting
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you start the program with the -mx512m settings? Where did you specify them?
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on the command line:

java -mx512m -version

also tried:

java -Xms512m -version

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That doesn't look correct. Look here; I think that is the Windows® version, but I don't think there are significant differences for other versions. I think it is
java -Xmx512M Foo
to run the Foo class' main method with a maximum space of 512MB.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:That doesn't look correct. Look here; I think that is the Windows® version, but I don't think there are significant differences for other versions. I think it is
java -Xmx512M Foo
to run the Foo class' main method with a maximum space of 512MB.



-Xmx is for max size,
-Xms is for intitial size.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Allasso Travesser wrote:

E Armitage wrote:what are your memory settings?



I don't know how to find that - I am using shared hosting




Well, how much memory does this hosted machine have? It doesn't matter what you memory setting are -- if you don't actually have enough memory allocated to run the JVM.

Henry
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:Well, how much memory does this hosted machine have? It doesn't matter what you memory setting are -- if you don't actually have enough memory allocated to run the JVM.

Henry



It seems to have enough memory if I am running the command via ssh - but when I run same command, same user (whoami verifies), via PHP script, suddenly it doesn't have enough memory?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Allasso Travesser wrote:
It seems to have enough memory if I am running the command via ssh - but when I run same command, same user (whoami verifies), via PHP script, suddenly it doesn't have enough memory?



Running the PHP interpreter (along with the PHP scripts) takes more memory than running nothing. So, running PHP with JVM needs more memory than just running the JVM.

Regardless, it is your decision. The error is reporting that it doesn't have enough memory. You can choose to examine other possible factors first.

Henry
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Allasso Travesser wrote:
It seems to have enough memory if I am running the command via ssh - but when I run same command, same user (whoami verifies), via PHP script, suddenly it doesn't have enough memory?



Running the PHP interpreter (along with the PHP scripts) takes more memory than running nothing. So, running PHP with JVM needs more memory than just running the JVM.

Regardless, it is your decision. The error is reporting that it doesn't have enough memory. You can choose to examine other possible factors first.

Henry



I suppose then it is a problem with the service provider not allocating enough memory?

[ Moderator edit - corrected the quote tags at Ranch time Nov 27, 2013 11:37:45. ]
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What OS is this on? On unix you can check the memory using free -m. (Run that with the PHP engine started)
You are going to need to know how to pass memory settings to your program, especially if you are going to run it on a shared host.
Read your PHP manual on the shell_exec command to find out how to execute your program with the correct memory settings. But first find out how much memory you actually have like Henry said.
 
Squanch that. And squanch this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic