Ikky
Ikky

Reputation: 2856

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:

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:

.

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.

Upvotes: 4

Views: 10957

Answers (3)

jean chen
jean chen

Reputation: 1

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

-XX:MaxPermSize=512m

-Xms512m

-Xmx512m

Upvotes: 0

Uri
Uri

Reputation: 89749

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.

Upvotes: 1

Joachim Sauer
Joachim Sauer

Reputation: 308031

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" ...

Upvotes: 6

Related Questions