Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (525)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Xmx ignored when used in Runtime.exec  (Read 726 times)
0 Members and 1 Guest are viewing this topic.
Offline P0jahn

Senior Devvie


Projects: 3



« Posted 2013-11-26 00:51:58 »

The Xmx and Xms is ignored in this code:
1  
2  
3  
4  
5  
Runtime.getRuntime().exec(new String[]{"java", "-jar", "-Xms1024m", "-Xmx1200m", "\"data.jar\""});

or

Runtime.getRuntime().exec("java -jar -Xms1024m -Xmx1200m \"data.jar\"");


I get out of memory error.

But when I run the very same code from a batch file, it works fine:
1  
java -jar -Xms1024m -Xmx1200m "data.jar"


Am I forgetting something? Why is the exec ignoring the Xmx and Xms arguments?
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 833
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2013-11-26 07:13:04 »

I'd shuffle the parameters to make -jar and the jar-path arguments consecutive. As to why it works from the commandline... you're probably launching a totally different jvm version (pass -version to verify) .

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline P0jahn

Senior Devvie


Projects: 3



« Reply #2 - Posted 2013-11-26 10:10:18 »

Well that did not work Sad

1  
java -jar \"data.jar\" -Xms1024m -Xmx1200m


I have no other version than java7 installed so it cant be that command line is launching a different version.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2013-11-26 11:13:06 »

What is you're doing that requires a 1.2GB heap? Seems suspiciously high.
There is another parameter that governs when you get OOMEs as well, which is the amount of heap reserved for native byte buffers. Are you running in to that?

Cas Smiley

Offline BoBear2681

JGO Coder


Medals: 19



« Reply #4 - Posted 2013-11-26 20:01:27 »

Note that any parameters after the jar name will be command line arguments to your program, not to the JVM.  Move the -Xms/-Xmx to be before the "-jar jarName" parameters.

1  
java -Xms1024m -Xmx1200m -jar "data.jar"

Offline P0jahn

Senior Devvie


Projects: 3



« Reply #5 - Posted 2013-11-26 20:41:10 »

Well, that did not work either. This small issue is getting frustrating! Tbh, I dont think its the arguments that is the problem, I think its the exec method from Runtime that is buggy.
The reason I say that is because the very same code work its launched from a batch file.

I tried the exec method from apache commons, still the same error though.
Offline princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2013-11-27 09:35:59 »

Attempt to pass a bogus value eg. -Xmx1k. It should fail.

Cas Smiley

Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #7 - Posted 2013-11-27 10:02:47 »

Well, that did not work either. This small issue is getting frustrating! Tbh, I dont think its the arguments that is the problem, I think its the exec method from Runtime that is buggy.
The reason I say that is because the very same code work its launched from a batch file.
Never put the blame on code that is not yours when you encounter a bug, that is very naive thinking. Always test for every single possibility.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (69 views)
2014-11-26 15:22:04

toopeicgaming1999 (58 views)
2014-11-26 15:20:36

toopeicgaming1999 (13 views)
2014-11-26 15:20:08

SHC (26 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (30 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (76 views)
2014-11-13 12:34:49

digdugdiggy (54 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!