I'm new in the Oracle world and I'm working with Oracle Identity Analytics (OIA). In the test environment everything is ok, but in production environment i'm getting an "java.lang.OutOfMemoryError", so when I checked the Xmx and Xms I saw that I had Xmx:512m and Xms:512m, that's why I'm trying to modify the Xmx value.
I want to modify the Xmx and Xms values so I wrote the following line in my PuTTY:
$ java -Xmx1024m
But the PuTTY shows me the following:
Usage: java [-options] class [args...] (to execute a class) or
java [-options] -jar jarfile [args...] (to execute a jar file)
where options include:...
Seems like I'm forgetting something after "Xmx1024m", but what? Well, now I know I'm forgetting Jar file, Class or App name but I have no idea how to get any of those things. I tried putting "$AdminServer" after "Xmx1024m" but it didn't work.
My Java version is 1.6.0_45 Oracle JRockit build R28 and the Operative Systems is Linux Server 6.5.
Regards!
You have to pass filepath to execute. Of course, you can run
java -Xmx1024m
but Java doesn't know what file should be executed
You will have to pass the program-name/filename/jar-name,whatever it is,with path for which you want to set/reset the java heap size.
e.g
java -Xms1024M -Xmx2048M -jar xi.jar
java -Xmx64m ${PROGRAM_NAME}
Hope this helps you.Or to help you better,could you please tell us what exactly is your scenario?
Related
I want to get GC logs from a program which runs on top of JVM. I know its possible to get those using
-Xloggc:GCLog.txt -verbose:gc -XX:+PrintGCDateStamps -XX:+UseSerialGC
parameters when running the application using
java -jar "jar_file".
But in this case I can't run the program in this manner by giving arguments, instead is there a way to specify them before running the application?
For an example we can set Xmx, Xms values using export
JVM_MEM_OPTS="-Xms100m -Xmx100m"
before running the java application.) Is there a similar way to specify GC parameters before running the application.
Thank you
For an example we can set Xmx, Xms values using export
JVM_MEM_OPTS="-Xms100m -Xmx100m"
This way is not standard and not referenced in the Java documentation.
JVM_MEM_OPTS, JAVA_OPTS or any environment variable will set the JVM options only because the tool/program that you use to start the JVM transmit it in the JVM options of the java command that is executed.
For example JAVA_OPTS is recognized in the Tomcat scripts (especially catalina.sh/bat).
-Xms100m -Xmx100m as -Xloggc:GCLog.txt -verbose:gc -XX:+PrintGCDateStamps -XX:+UseSerialGC are JVM options.
If you don't want to pass directly these options in the java command, you have to do as the tools that allows to use a custom environment variable : create a script (specific to the OS) that uses this environment variable as value of the JVM options such as (linux way):
java $JAVA_OPTS -jar "jar_file"
When running JMeter, java server has the -Xmx value of only 512 MB. I tried to change it via following code in the jmeter.bat.sh file.
set HEAP=-server -Xms512m -Xmx6144m
set NEW=-XX:NewSize=512m -XX:MaxNewSize=6144m
also tried this:
set HEAP= -Xms512m -Xmx6144m
set NEW=-XX:NewSize=512m -XX:MaxNewSize=6144m
By checking the process after while JMeter is running I can see that java -sever doesn't recognize this setting.
If you are running jmeter startup script on Linux the syntax will be different, i.e:
HEAP="-Xms512m -Xmx6G"
as SET command is something Windows-specific
Alternatively you can define JVM_ARGS environment variable value like:
JVM_ARGS="-server -Xms512m -Xmx6G" && export JVM_ARGS
this way you won't need to edit files and/or restart JMeter.
Finally, you can launch JMeter jar directly like:
java -server -Xms512m -Xmx6G -jar ApacheJMeter.jar
See the following reference material:
Tuning Java Virtual Machines (JVMs)
JMeter Best Practices
9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure
I want to alter (increase) java memory limit (JRE on windows pc).
I fount following commands everywhere:
-Xms set initial Java heap size
-Xmx set maximum Java heap size
for example -Xmx1024m.
But my Question is where! do I have to enter this command. Sorry for this beginner question. Normally I do not have any contact to java.
If you are using eclipse and try to run standalone java then use vm argument section in run configuration tab .For tomcat or app server in setenv script file put
set JAVA_OPTS=-Xms1024m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=384m
for executable jar
java -Xms1024m -Xmx1024m -jar FILENAME.jar
Those are Arguments for the Virtual Machine that you pass in the command line when you start the app
example:
in the console doing:
java -Xms256m -Xmx1024m HelloWorld
or if you are in eclipse (or any other ide)
Is ist possible to start a java application with the -X parameters?
I have tried java -jar -Xmx=256m myAppl.jar but with no success.
Is there a possibiliy to do this?
Xmx parameter does not need = symbol, just write Xmx256m
It's more convenient to set it before -jar parameter.
java -Xmx256m -jar myapp.jar
Anyway since you get OutOfMemoryError, I think that = symbol is just a typo (JVM can't start with invalid Xmx parameter) and the real problem is lack of memory. Try to increase it.
I have a .JAR that apparently uses up too much memory, and throws an exception "Java heap space" (or something similar).
So I tried running the .JAR via the CMD like this:
C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m
That did not solve the problem. Same error.
Now, when I checked the Processes tab in the windows task manager, I noticed that the process of my jar has a lot less memory than what i asked for (same as running it without the parameters).
Why is it ignoring the parameters?
Also, I think the exception is thrown around the time the process reaches 100mb of memory usage. Is it possible that the GC is trying to free up the memory and that's what causes the problem? Is there any parameter I can set for the GC to prevent that?
Thanks, Malki :)
The Command
javaw -jar MyJar.jar -Xms64m -Xmx128m
will use -Xms... and -Xmx... as parameters to the "main(String[] args)" method.
Parameters to the JVM must be passed before the -jar part:
javaw -Xms64m -Xmx128m -jar MyJar.jar
The reason for that can be seen when we execute "java -version" :
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
Where your parameters -Xms... and -Xmx... are options to the JVM.