2
JAVA -Xms500M -Xmx1800M -XX:+UseConcMarkSweepGC -classpath C:\XYZ\MY_installer\lib\jlex.jar;C:\XYZ\MY_installer\lib\antlr.jar;C:\XYZ\MY_installer\lib\mytemplate.jar;C:\XYZ\MY_installer\lib\log4j-1.2-api-2.0-beta8.jar;C:\XYZ\MY_installer\lib\log4j-api-2.0-beta8.jar;C:\XYZ\MY_installer\lib\log4j-core-2.0-beta8.jar;C:\WORKSPACES\delnaz\del_prj;  -DENVFILE=C:\XYZ\MY_installer\bin\escat.ini utilities.graph.GraphDriver C:\XYZ\MY_installer "C:\WORKSPACES\delnaz\del_prj\del.prj" "C:\WORKSPACES\delnaz\del_prj" 1

Problem: This is command which needed above descripted jar for enviornment, is working if i shift max heap size 1400 to 1000 though I know jars are not going to do any thing with heap. but i want to know the reason why it is changing, or what could be the reason.

String cmdArr[] = {"cmd.exe", "/C" , cmdString};
                    ProcessBuilder pb = new ProcessBuilder(cmdArr);
                    Map<String, String> env = pb.environment();
                    env.put("PATH", System.getenv("PATH"));
                    env.put("ROOT", rootPath);
                    env.put("SYSTEMROOT", System.getenv("SYSTEMROOT"));
                    if(cmdString.endsWith("cfe.bat"))
                        pb.directory(new File("TextFiles"));
                    else
                        pb.directory(new File(Workspace_path));
                    process = pb.start();

java version is:

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)

Windows 7 Enterprise

RAM 4GB

32 bit OS

And another startegy: Reason why we needed Maxheap size can we not have option in which we can look in to run application on standard option.

RTA
  • 1,251
  • 2
  • 14
  • 33

3 Answers3

2

These two command options

-ms500M -mx1800M

Should be

-Xms500M -Xmx1800M
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

Are you using a 32 bit version of JDK?

The 32 bit JDK has a max heap size limit (just like a 32 bit OS can't use more than 4GB RAM).

Use a 64 bit version of the JDK (assuming you have a 64 bit OS).

EDIT:

Since you have now mentioned that you are using a 32 bit OS, I have some bad news for you.

You cannot increase the heap size unless you move to a 64 bit system.

Check this for more info: https://stackoverflow.com/a/7019624/1862828

The only solution for this would be to refactor your program so that it uses less memory and use a smaller value for Xmx like -Xmx1000M.

Community
  • 1
  • 1
atripathi
  • 898
  • 3
  • 11
  • 17
  • @tripathi it was working fine some days before on -Xmx1400M but now it is working on -Xmx(1000 to 1390): Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. – RTA Dec 17 '13 at 06:43
  • The 32 bit JDK is the culprit. You cannot use more than 1400M with it. I had faced the same problem myself, a few months back. – atripathi Dec 17 '13 at 06:52
  • but have not any specification for 32 bit jdk for my application..and question is before it was working fine...okay agree 1.4G to 1.6G but in some system it is not working on even 1200M..this variation hurts..I know it could because of system use – RTA Dec 17 '13 at 07:03
  • Reason why we needed Maxheap size can we not have option in which we can look in to run application on standard option. if currently not want to dip in to memory optimzation techniques. At basic level I have tested not so much coding flaws are there – RTA Dec 17 '13 at 07:10
  • It depends on the amount of memory available to the JVM when it starts. If there is just 1000M free, and the JVM asks for 1200M, it won't get it, will it? Either you modify your program so that it uses less memory or you move to a 64 bit system and increase your RAM. – atripathi Dec 17 '13 at 07:11
  • you are talking about object nullify, over heap use and thread synchronization code check, collection optimization. i did it but not helps alot. I am looking for any quick fix(knows better sooner or later i have to find the cause) – RTA Dec 17 '13 at 08:32
0

This will only work with 64 bit version of java.

Go to control panel> java icon. Open small window of java control panel.

Click on java menu bar >view button.

If you have two java platform ,disable previous version of java, then click on Runtime parameters text field.

Write down here -Xmx1024m or less than RAM SIZE. Don't increase heap size equal to RAM, otherwise your system will be crash.

Shiva
  • 6,677
  • 4
  • 36
  • 61
madhu
  • 53
  • 1