Set heap size for Java on Bitbucket Server and Data Center
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Sometimes, you might need to change JVM parameters for heap size on Bitbucket (Xms and Xmx). To do this, edit the files and restart Bitbucket to apply the changes.
Environment
Applies to Bitbucket on-premise installations on Windows and Linux environments.
Solution
For Windows
Take the following steps:
- Through the command line, go to the Bitbucket binary folder:
cd <Bitbucket Server installation directory>\bin
. - Access the Bitbucket process:
bservmgr.exe //ES//AtlassianBitbucket
. - In the pop-up window, select the Java tab and edit the Initial Memory Pool and Maximum Memory Pool values.
For Linux
Method 1 RECOMMENDED
Set and export the JVM_MINIMUM_MEMORY and JVM_MAXIMUM_MEMORY environment variables at the OS level. This will preserve the set values that may otherwise be overwritten by Bitbucket upgrade activities.
Method 2
The following configuration changes will only affect currently installed Bitbucket version.
They will need to be re-applied after each upgrade.
- Through the command line, go to the Bitbucket binary folder:
cd <Bitbucket Server installation directory>/bin
. - Open the Bitbucket Webapp process:
vi _start-webapp.sh
. - Edit the JVM_MINIMUM_MEMORY and JVM_MAXIMUM_MEMORY values.
# The following 2 settings control the minimum and maximum memory allocated to the Java virtual machine.
# For larger instances, the maximum amount will need to be increased.
#
if [ -z "${JVM_MINIMUM_MEMORY}" ]; then
JVM_MINIMUM_MEMORY=512m
fi
if [ -z "${JVM_MAXIMUM_MEMORY}" ]; then
JVM_MAXIMUM_MEMORY=1g
fi