开发者

Problems with java heap space, how to increas the heap size?

I'm running a ".bat" file which points to asant:

C:\Sun\SDK\bin\asant Startbds

asant again points to a xml file i've got, build.xml:

<target name="Startbds" description="Start bds">

This has been fine for now, but now i have added more data, which leads to an out of memory error:

开发者_StackOverflow社区
java.lang.outOfMemoryError: Java heap space

So i've tried to increase the heap space by various methods i've found while searching around for a solution:

  • cmd: set ANT_OPTS=-Xms512m -Xmx512m (did not work, same error message)
  • Editing the asant.bat where i edited the line "-set ANT_OPTS" from

.

set ANT_OPTS="-Dos.name=Windows_NT" -Djava.library.path=%AS_INSTALL%\lib;%AS_ICU_LIB%;%AS_NSS%" "-Dcom.sun.aas.installRoot=%AS_INSTALL%" "-Dcom.sun.aas.instanceRoot=%AS_INSTALL%" "-Dcom.sun.aas.instanceName=server" "-Dcom.sun.aas.configRoot=%AS_CONFIG%" "-Dcom.sun.aas.processLauncher=SE" "-Dderby.root=%AS_DERBY_INSTALL%"  

TO

set ANT_OPTS="-Xms512m -Xmx512m" "-Dos.name=Windows_NT" -Djava.library.path=%AS_INSTALL%\lib;%AS_ICU_LIB%;%AS_NSS%" "-Dcom.sun.aas.installRoot=%AS_INSTALL%" "-Dcom.sun.aas.instanceRoot=%AS_INSTALL%" "-Dcom.sun.aas.instanceName=server" "-Dcom.sun.aas.configRoot=%AS_CONFIG%" "-Dcom.sun.aas.processLauncher=SE" "-Dderby.root=%AS_DERBY_INSTALL%"  

but this gave me the error message:

"Invalid initial heap size: -Xms512m -Xmx512m
 Could not create the Java virtual machine."

Anyone got an idea of how i should increase the heapsize? And maybe also give a pointer to where i can find a tool to watch the heapsize.

Thanks in advance.


By using "-Xms512m -Xmx512m" you gave a single argument. -Xms expects the minimum heap size to be specified by the rest of the argument. So you defined the minimum heap size to be "512m -Xmx512m", which is not a valid value.

You will want to provide those switches as two arguments:

set ANT_OPTS=-Xms512m -Xmx512m "-Dos.name=Windows_NT" ...


I think that if you're in windows, you don't need the double quotes in your set. Here is an example I saw somewhere:

set ANT_OPTS=-Xms512m -Xmx512m  (Windows)
export ANT_OPTS="-Xms512m -Xmx512m"  (ksh/bash)
setenv ANT_OPTS "-Xms512m -Xmx512m"  (tcsh/csh)

As for monitoring heap usage, if you are using the most recent JDK on Windows, you should have Sun's VisualVM.


In eclipse -> window -> preferences -> Tomcat -> JVM Setting -> Append to JVM Parameters:

-XX:MaxPermSize=512m

-Xms512m

-Xmx512m
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜