I'm getting Invalid maximum heap size when I set Xmx and agentlib
Here are the arguments that I am using:
-Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11999
The -Xmx1024m work fine without passing the -agentlib, and the -agentlib works fine witho开发者_如何转开发ut Xmx. Can you set the max heap size while using the agentlib?
My jar file is getting launched via C code:
execlp(myJavaPath, myJavaPath, myDebugOptions,"-DFBLog4j=true","-jar","myJar.jar", NULL);
Where myDebugOptions contain the char* "-Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11999". When I try to run this same command via commandline (in Solaris 10, JVM 1.6.0_17) it works fine.
You have to pass each command line argument as different parameters to execlp.
The commandline you're executing would be the same as running this from a command line:
java '-Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11999' -DFBLog4j=true -jar myJar.jar
Which won't work either, essentially -Xmx and -agentlib gets passed as a single argument.
The reason this doesn't work is because -Xmx1024 and -agentlib: are two different arguments. When calling execlp they need to be passed in as two different arguments. When I called execlp like:
execlp(myJavaPath, myJavaPath, myDebugOptions, "-Xmx1024m", "-DFBLog4j=true", "-jar", "/usr/mprint/bin/QDirectJServer.jar", NULL);
it worked as expected with no errors. Even those myDebugOptions contained a space it was still considering it as one argument.
If your defined memory capacity is greater than your system physical memory then this kind of error will generate.
update defined memory according t the physical memory.
For Example if your physical memory of Ram is 2GB(2048m) and yo defined the JVM as -Xmx4096m then this error will come.
i tried this one and it worked :
C:\Documents and Settings\Administrator>java -Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=11999 -version
Listening for transport dt_socket at address: 11999
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode)
精彩评论