aspose file tools*
The moose likes Java in General and the fly likes Question about Java heap size and the manifest file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Question about Java heap size and the manifest file" Watch "Question about Java heap size and the manifest file" New topic
Author

Question about Java heap size and the manifest file

AkumaX AkumaX
Greenhorn

Joined: Jan 26, 2005
Posts: 4
Hi all!

Recently I've been developing a small game engine in Java, which loads many png and jpg files and the default heap size that the JVM gives (64mb) seems to not be enough. I solved that matter by adding the following switches, as instructed by tutorials around the net:

-Xss2048k -Xms64m -Xmx256m -Xmn50m -XX:+UseParallelGC -XX:+UseAdaptiveSizePolicy

256 max heap size will be enough for my case!

The problem is that now I have to use a command-line to start the engine, as follows:

java -Xss2048k -Xms64m -Xmx256m -Xmn50m -XX:+UseParallelGC -XX:+UseAdaptiveSizePolicy -jar GameEngine.jar

Is there a way to include all these JVM options directly in the manifest file? In that way, I can skip the batch file and start the engine directly by double-clicking the jar file. I've been searching on the net the last couple of hours for that matter but I couldn't find a concrete answer.


Right now the manifest file includes only the following:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0_03-b07 (Sun Microsystems Inc.)
Main-Class: com.zefxis.SolarWind.GameMain
X-COMMENT: Main-Class will be added automatically by build


And another question:
The engine can be used in applet mode directly, with the same jar file. In that case, the browser directly initializes the GameApplet.class file through an <applet> or <object> tag. How can I include the above named JVM options when in applet mode without a manifest file? Can that be done through the html page and the above tags? Or does the applet read its manifest file? Is there a solution for this matter?

Right now, I managed to run the engine when in applet mode through Sun's own appletviewer by the below command-line argument:
"C:\Program Files\Java\jdk1.5.0_03\bin\appletviewer" -J-Xss2048k -J-Xms64m -J-Xmx256m -J-Xmn50m -J-XX:+UseParallelGC -J-XX:+UseAdaptiveSizePolicy "EngineApplet (applet tag).html"

As you can see above I use Sun's latest developer tools, i.e. jdk 1.5.0_03 and netbeans 4.1 for writing the engine.

Thanx in advance for any opinions for this matter!

AkumaX
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
java -Xss2048k -Xms64m -Xmx256m -Xmn50m -XX:+UseParallelGC -XX:+UseAdaptiveSizePolicy -jar GameEngine.jar

First off I would drop all but one of those switches unless you have metrics that show improvements as hard numbers. Keep -Xmx256m if that's how much you really need. As far as using the manifest to specify these options, those are non-standard options so you would not want that. Moreover, the applet runs in an existing JVM and does not get to dictate any JVM options.
AkumaX AkumaX
Greenhorn

Joined: Jan 26, 2005
Posts: 4
Rick O'Shay thanks for the quick reply.

So, in applet mode there is no control of the JVM options, so I cannot use my engine with a bigger heap size in that mode, except of using appletviewer for test purposes? Seems rather odd that Sun didn't provide a solution for this matter.

I'll follow your advice about dropping most of the switches after doing some benchmarking of the engine. Thanks for also pointing that out.

Could you point out to me the non-standard options that I may include in the manifest file to avoid all the command-line switches? I understand that being non standard they may stop working in a newer Java version without proior notice, but at least I would be avoiding the command-line options for the time being.

Thanks in advance for the help!

AkumaX
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Why don't you write your options to a startscript?


http://home.arcor.de/hirnstrom/bewerbung
AkumaX AkumaX
Greenhorn

Joined: Jan 26, 2005
Posts: 4
Startscript? I didn't know that something like that existed in Java. How can I implement something like that with a startscript? Any link/tutorial that I can use?

Thanx guys

AkumaX
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

There is no startscript IN java, but your OS might have something.

On linux (?solaris): start.sh

On windows: start.bat
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about Java heap size and the manifest file