views:

578

answers:

2

Hello.

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:

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

+5  A: 

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" ...
Joachim Sauer
Thanks for the tip. I did not receive the error message:"Invalid initial heap size: -Xms512m -Xmx512m Could not create the Java virtual machine."But i still got the problem with Java heap space.
I have tried to increase the page size on c: to 5Gb, and then tried to increase the heap size to 4gb, but now i get the errormessage: "Could not reserve enough space for object heap".Is there a limit?
@ikky: one limit is the physical ram available in your machine. Another one is the maximum size of heap a single process can have (I think that's 2GB on 32bit Windows) minus some amount that the JVM needs for other parts.
Joachim Sauer
+1  A: 

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.

Uri
I'll check that out. Thank you.