How do I increase the memory used by my Weblogic (Java). While starting the server from eclipse it shows a message that JAVA Memory arguments: -Xms256m -Xmx512m -XX:MaxPermSize=256m. I couldn't understand from where is it taking that value from. After sometime the Weblogic server fails because of low permgen space.
I added startup arguments from console but that doesn't have any effect. Can you help me from where is it taking the memory values from?
When you configure a "Server" in Eclipse for WebLogic, you select a domain directory (for local). That domain directory contains the startup scripts that Eclipse will use to start the WebLogic Server. These are the same scripts that you would use if you started the server if you did it without Eclipse. Inside the domain directory is a folder called "bin". In the "bin" directory, locate the setDomainEnv file (.sh for unix, or .cmd for Windows). In that file, alter the memory settings to suite your needs.
Based on the error message you mentioned in your question, I would increase both the PermSize and MaxPermSize settings to 512m. For PermSize and MaxPermSize, there are two locations each by default in a simple WLS installation, one for 32-bit, and another for 64-bit. It won't hurt to change them both. But if you know which JVM architecture you are running, you can change the one that applies to your environment.
You will have a file setDomainEnv.cmd/setDomainEnv.sh under your server bin folder. this file contains
set MEM_MAX_PERM_SIZE_64BIT=-XX:MaxPermSize=512m
set MEM_MAX_PERM_SIZE_32BIT=-XX:MaxPermSize=512m
Max and Min memory values as
if "%JAVA_VENDOR%"=="Sun" (
set WLS_MEM_ARGS_64BIT=-Xms256m -Xmx512m
set WLS_MEM_ARGS_32BIT=-Xms256m -Xmx512m
) else (
set WLS_MEM_ARGS_64BIT=-Xms512m -Xmx512m
set WLS_MEM_ARGS_32BIT=-Xms512m -Xmx512m
)
You can update the values inside it.
In addition to the previous two answers that are correct (modifying setDomainEnv and potentially wl_server\common\bin\commEnv), you can also modify servers individually if you are starting them with the nodemanager.
In the admin console navigate to:
Servers -> <server name> -> Server Start tab -> Arguments
Here you can set the JVM args you want for that server rather than making a blanket change in all servers to setDomainEnv
Looks like eclipse plugin adds it own USER_MEM_ARGS variable, so it should be rewritten using following approach:
Open following file:
$WL_HOME/user_projects/domains/mydomain/bin/setDomainEnv.sh
and add the next line to it (e.g. after help description)
USER_MEM_ARGS=$ECLIPSE_MEM_ARGS
Then, open weblogic server properties (double click at weblogic in servers view) and click "Open launch configuration". In a opened window select "Environment" and add new variable ECLIPSE_MEM_ARGS with memory params as value, e.g.:
ECLIPSE_MEM_ARGS=-Xms1024m -Xmx2048m -XX:MaxPermSize=512m
Save and check that server was applied new configuration.
P.S. Using this approach you can change/add memory params directly from eclipse.
P.S.S. In Windows you should use setDomainEnv.cmd file and added line should be:
set USER_MEM_ARGS=%ECLIPSE_MEM_ARGS%
For Weblogic12:
Environment->Servers->[your_server]->Configuration/Server Start -> Arguments:
-Xms1024m -Xmx2048m
Restart the server:
Environment->Servers->[your_server]->Control/"Start/Stop" -> Suspend and then Start.
Check your memory:
Environment->Servers->[your_server]->Monitoring/Performance.
Related
I've been trying to automate the creation of our development environment by combining batch files and WLST, but I am struggling to change the memory WebLogic server will start with.
Currently we are manually changing the memory settings in the <DOMAIN_HOME>/bin/setDomainEnv.cmd script, but this is a workaround. It should be possible to to do it automatically without much effort.
Setting the Domain
The script that sets the Domain in pretty simple:
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_45
set MW_HOME=C:\dev\wls1036_dev
set DOMAIN_HOME=C:\dev\domain
cd %MW_HOME%
call configure.cmd
mkdir %DOMAIN_HOME%
cd %DOMAIN_HOME%
%JAVA_HOME%\bin\java.exe -Xmx1024m -XX:MaxPermSize=256m -Dweblogic.management.username=weblogic -Dweblogic.management.password=welcome1 weblogic.Server
I've tried to use some variables in this script such as MEM_ARGS, JAVA_OPTIONS, but none of these are forwarded to the final configuration of the domain, later it always starts with 512 heap, and 128 perm, which are not enough.
WLST memory start args
We are using Eclipse, and it does call the startWebLogic.cmd as start script. It is the standard configuration.
I tried to use the following WLST script. It does set the server start arguments, but WebLogic is not using those properties and loads not enough memory.
edit()
startEdit()
cd('/Servers/myserver/ServerStart/myserver')
cmo.setArguments('-Xmx1024m -XX:MaxPermSize=256m')
activate()
Any ideas?
You can use the trick for getting ServerStart arguments:
Write simple offline WLST-script to get arguments from config.xml:
getArguments.py
import sys
readDomain(sys.argv[1])
cd('Server/%s/ServerStart/NO_NAME_0' % sys.argv[2])
argsFile = open('arguments.txt', 'w')
print >>argsFile, cmo.arguments
Add this script to startWeblogic.cmd like:
startWebLogic.cmd
...
set DOMAIN_HOME=%~dp0
path\to\wlst.cmd getArguments.py %DOMAIN_HOME% admin_server_name
set /p EXTRA_JAVA_PROPERTIES=<arguments.txt
call "%DOMAIN_HOME%\bin\startWebLogic.cmd" %*
There is no easy way of setting values when executing WebLogic from Eclipse. It'll call the batch script and, at least at current version, does not allow to send dynamic parameters.
We solved it making the setDomainEnv.cmd file part of our versioned configuration:
Copy the setDomainEnv.cmd file to your version control configuration.
Edit whatever you want (memory, etc)
Copy the file like copy custom\setDomainEnv.cmd %DOMAIN_HOME%\bin /y when running your development environment configuration script.
Now every time you configure your development environment memory values will be ready without manual intervention.
You have to reedit your stuff when updating WebLogic, so you don't end up with an outdated component.
i had Fusion Reactor Installed on my Machine, I unstalled other Day, the Folder for Fusion reactor was still there and I was not able to delete it, I found the JVM config file has still some entries, I want to remove those, What entries from the below should be removed, so i can delete my fusion reactor folder
Thanks
Here is the JVm Config File Code
# Arguments to VM
java.args=-server -Xms256m -Xmx1024m -XX:MaxPermSize=192m -XX:+UseParallelGC -Xbatch -Dcoldfusion.home={application.home} -Dcoldfusion.rootDir={application.home} -Dcoldfusion.libPath={application.home}/lib -Dorg.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER=true -Dcoldfusion.jsafe.defaultalgo=FIPS186Random -javaagent:C:/FusionReactor/instance/cfusion.cf10/fusionreactor.jar=name=cfusion.cf10,address=8088 -agentpath:C:/FusionReactor/instance/cfusion.cf10/frjvmti_x64.dll -Dcoldfusion.classPath={application.home}/lib/updates,{application.home}/lib,{application.home}/lib/axis2,{application.home}/gateway/lib/,{application.home}/wwwroot/WEB-INF/flex/jars,{application.home}/wwwroot/WEB-INF/cfform/jars
As #beloidavisja suggested you should remove the javaagent and agentpath arguments from the jvm config. Those are the arguments required for fusionreactor. After removing the arguments from the config file make sure to restart ColdFusion server. A restart is required for the changes to take effect. Read this http://docs.intergral.com/display/FR51/Manual+Installation
I need to pass a couple of JVM arguments to the JVM which Tomcat is running in so that my application can pick them up.
I want to follow the process outlined in this article to pick up environment variables.
How would I go about doing this?
UPDATE
Sorry This is running under windows (7 on my Dev machine 2003 on client server)
Windows:
In your Tomcat /bin folder, you should have a tomcat5w.exe admin app (or in later versions tomcat6w.ex, tomcat8w.exe, etc). Go to the Java tab and add the args in the "Java Options:" box.
Note that when you add new args, you need to add them as NEW LINES in that box (above or below any others there), not as additional arguments IN FRONT or BACK of values on one of the existing lines.
Linux / UNIX:
In *nix, changes to the setenv.sh file should be picked up:
export JAVA_OPTS=-server -Xms2g -Xmx4g -XX:PermSize=64m -XX:MaxPermSize=256m $JAVA_OPTS
Don't touch catalina.sh or other files in bin
You need to edit the Windows service. There are three ways to do this:
Start Tomcat5w with //MS//ServiceName to get an icon in the system tray which gives you a quick access to the configuration of the service.
Open the service manager in the "Control Panel". There is an entry for Tomcat.
In the editor, there is a tab where you can add additional JVM parameters.
The third way (which I prefer) is to write a script which edits the config for you. This way, you can save the config somewhere for backup. See the docs how to do that (Hint: use tomcat5 //US//...)
There are lots of questions that ask this or a similar question.
They all give the command that has to be executed, what I don't understand is where do I write this command. I want to permanently increase the heap space for my tomcat apps.
I read this page http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html and it says under the Tomcat section
Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,
set CATALINA_OPTS=-Xms512m -Xmx512m (Windows, no "" around the value)
export CATALINA_OPTS="-Xms512m -Xmx512m" (ksh/bash, "" around the value)
setenv CATALINA_OPTS "-Xms512m -Xmx512m" (tcsh/csh, "" around the value)
So I replaced the line
set CATALINA_OPTS=
with
set CATALINA_OPTS=-Xms512m -Xmx512m
But I still get the error.
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.OutOfMemoryError: Java heap space
java.lang.reflect.Array.multiNewArray(Native Method)
java.lang.reflect.Array.newInstance(Array.java:90)
nom.tam.util.ArrayFuncs.newInstance(ArrayFuncs.java:1028)
nom.tam.fits.ImageData.read(ImageData.java:259)
nom.tam.fits.Fits.readHDU(Fits.java:573)
controller.UploadServlet.retreiveFITSFileFields(UploadServlet.java:206)
controller.ScanServerFiles.doPost(ScanServerFiles.java:39)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
There is a mechanism to do it without modifying any files that are in the distribution. You can create a separate file %CATALINA_HOME%\bin\setenv.bat or $CATALINA_HOME/bin/setenv.sh and put your environment variables there. Further, the memory settings apply to the JVM, not Tomcat, so I'd set the JAVA_OPTS variable instead:
set JAVA_OPTS=-Xmx512m
First of all you cannot change the memory settings only for a tomcat application but rather for all tomcat instance.
If you are running tomcat from console (using startup.bat) you'll need to edit catalina.bat and play around with CATALINA_OPTS. For example:
set CATALINA_OPTS=-Xms512m -Xmx512m
Restarting tomcat will apply the new settings.
If you are still getting OutOfMemoryError you need to know how much memory does your application need at that particular moment (nom.tam.util.ArrayFuncs...). You'll either have to optimize the application or simply increase the memory provided to tomcat.
Your change may well be working. Does your application need a lot of memory - the stack trace shows some Image related features.
I'm guessing that the error either happens right away, with a large file, or happens later after several requests.
If the error happens right away, then you can increase memory still further, or investigate find out why so much memory is needed for one file.
If the error happens after several requests, then you could have a memory leak - where objects are not being reclaimed by the garbage collector. Using a tool like JProfiler
can help you monitor how much memory is being used by your VM and can help you see what is using that memory and why objects are not being reclaimed by the garbage collector.
Open the server tab in eclipse
right click open
click on open lauch configuration
Go to arguments
Here you can add in VM arguments after endorsed
-Xms64m -Xmx256m
You need to add the following lines in your catalina.sh file.
export CATALINA_OPTS="-Xms512M -Xmx1024M"
UPDATE : catalina.sh content clearly says -
Do not set the variables in this script. Instead put them into a script setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
So you can add above in setenv.sh instead (create a file if it does not exist).
Easiest way of doing is: (In Linux/Ububuntu e.t.c)
Go to tomcat bin directory:
cd /opt/tomcat8.5/bin
create new file under bin directory "setenv.sh" and save below mention entries in it.
export CATALINA_OPTS="$CATALINA_OPTS -Xms512m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx2048m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"
and issue command:
./catalina.sh run
In your catalina log file you can see entry like this:
INFO [main] VersionLoggerListener.log Command line argument: -Xms512m
INFO [main] VersionLoggerListener.log Command line argument: -Xmx2048m
INFO [main] VersionLoggerListener.log Command line argument: -XX:MaxPermSize=256m
Which confirms that above changes took place.
Also, the value of "Xms512m" and "-Xmx2048m" can be modified accordingly in the setenv.sh file.
Startup of tomcat could be done in two steps as well.
cd /opt/tomcat8.5/bin
Step #1
run ./setenv.sh
Step #2
./startup.sh
If you're using systemd edit:
/usr/lib/systemd/system/tomcat8.service
and set
Environment=CATALINA_OPTS="-Xms512M -Xmx2048M -XX:MaxPermSize=256m"
if you are using Windows, it's very simple. Just go to System Environnement variables (right-clic Computer > Properties > Advanced System Parameters > Environnement Variables); create a new system variable with name = CATALINA_OPTS and value = -Xms512m -Xmx1024m. restart Tomcat and enjoy!
For Windows Service, you need to run tomcat9w.exe (or 6w/7w/8w) depending on your version of tomcat.
First, make sure tomcat is stopped. Then double click on tomcat9w.exe. Navigate to the Java tab. If you know you have 64 bit Windows with 64 bit Java and 64 bit Tomcat, then feel free to set the memory higher than 512. You'll need to do some task manager monitoring to determine how high to set it. For most apps developed in 2019... I'd recommend an initial memory pool of 1024, and the maximum memory pool of 2048. Of course if your computer has tons of RAM... feel free to go as high as you want.
Also, see this answer: How to increase Maximum Memory Pool Size? Apache Tomcat 9
you can set this in catalina.sh as CATALINA_OPTS=-Xms512m -Xmx512m
Open your tomcat-dir/bin/catalina.sh file and add following line anywhere -
CATALINA_OPTS="$CATALINA_OPTS -Xms1024m -Xmx3024m"
and restart your tomcat
Just set this extra line in catalina.bat file
LINE NO AROUND: 143
set "CATALINA_OPTS=-Xms512m -Xmx512m"
And restart Tomcat service
I am running multiple tomcats on a Red Hat box and I would like to configure separate heap size for each of them (some instances use more memory).
Can I set the heap size min/max bt entering the following into the catalina.sh file:
CATALINA_OPTS="-Xms64m -Xmx256m"
Do I need add 'export'? i.e. export CATALINA_OPTS="-Xms64m -Xmx256m"
Best practice is to put the setting of environment variables in a file named setenv.sh/.bat in the bin folder.
The catalina.sh script has logic to call into this script, if it exists.
The reason why this is recommended is because it makes setting of environment variables needed for your installation portable: you can easily copy setenv.sh to other Tomcat installations, you can upgrade Tomcat to a newer version (which might overwrite catalina.sh) but still have your existing setenv.sh.
An example on how to set the heap size inside setenv.sh:
export JAVA_OPTS='-Xmx784M`
If you add this to anything in the Tomcat installation, it will affect all instances run on that machine.
I think you want to set JAVA_OPTS separately, in separate scripts, which each then invoke Tomcat's startup script. The scripts can set different heap sizes. Yes, you need to export.