Sunday, 27 June 2021

Customizing the WebLogic JVM heap size

Scenario 1:

We need to change the memory arguments to a value same for all servers in a Domain. 

You can change the default JVM heap size to fit the needs of your deployment.

The default JVM heap size for WebLogic is 3GB. The size is set in the setDomainEnv.sh file for Linux or setDomainEnv.cmd for Windows, which is in the $DOMAIN_HOME/bin directory. The heap size is set with the -Xmx option.

Suppose we want to keep Xmx 3072 M and Xms 128 M for all server in an Domain (Admin and all managed servers).

We will edit setDomainEnv.sh in $DOMAIN_HOME/bin with our required values of Xmx and Xms. 

To change the WebLogic JVM heap size:
  1. Open the setDomainEnv file in a text editor.
  2. Search for this comment line:
    For Linux:
    # IF USER_MEM_ARGS the environment variable is set, use it to override ALL MEM_ARGS values
    For Windows:
    @REM IF USER_MEM_ARGS the environment variable is set, use it to override ALL MEM_ARGS values
  3. Immediately after the comment line, add one of these lines:
    For Linux:
    export USER_MEM_ARGS="-Xms128m -Xmx3072m ${MEM_DEV_ARGS} ${MEM_MAX_PERM_SIZE}"
    For Windows:
    set USER_MEM_ARGS=-Xms128m -Xmx3072m %MEM_DEV_ARGS% %MEM_MAX_PERM_SIZE%
  4. Save the file.
  5. Re-start WebLogic Server.

This will set Xms to 128 MB and Xmx to 3072 MB for Admin server as well as Managed servers.


Scenario 2:

We need to change the memory arguments to values different for all servers in a Domain. Suppose we want to keep 
                Xmx 1024M and Xms 1024M for Admin server 
                and
                Xmx 1g and Xms 4g for WLS_FORMS Managed server

We will edit setDomainEnv.sh in $DOMAIN_HOME/bin with our required values of Xmx and Xms.

Search for line “# IF USER_MEM_ARGS the environment variable” in setDomainEnv.sh
We will add lines below the comment


#Admin Server

if [ "${SERVER_NAME}" == "AdminServer" ] ; then
USER_MEM_ARGS="-Xms1024m -Xmx1024m -XX:MaxPermSize=1024m"
export USER_MEM_ARGS
fi

#WLS_FORMS Managed server

if [ "${SERVER_NAME}" == "wls_forms1" ] ; then
USER_MEM_ARGS="-Xms1024m -Xmx4096m -XX:MaxPermSize=4096m"
export USER_MEM_ARGS
fi



Increasing the Java Heap size for a managed server

 If you use Node Manager to start the Managed Servers, you can specify a heap size as a Java argument on the Server Start tab for each Managed Server.

To change the Java Heap size for a managed server:

  1. If you have not already done so, in the Change Center of the Administration Console, click Lock & Edit .
  2. In the left pane of the console, expand Environment > Servers.
  3. In the Servers table, click the name of the server instance you want to configure.
  4. On the Configuration tab, click Server Start.
  5. In the Arguments field, specify the Java option to increase the heap size. For example: -Xmx1024m
  6. Click Save.
  7. To activate these changes, in the Change Center of the Administration Console, click Activate Changes.
  8. Restart Managed Servers.
  9. Possibly restart the server if needed.

For better consistency it is good to update the parameters at both location - console and setDomain file.

OR

Add below entries into setDomain.sh file





Thank You !

No comments:

Post a Comment