# How to increase java memory Ubuntu Server 20.04?

**URL:** <https://community.jenkins.io/t/how-to-increase-java-memory-ubuntu-server-20-04/2098>\
**Category:** Using Jenkins\
**Tags:** question, sig-infra\
**Created:** [April 13, 2022, 9:10am UTC](https://community.jenkins.io/t/how-to-increase-java-memory-ubuntu-server-20-04/2098 "2022-04-13T09:10:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flachica](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/flachica/32/1296_2.png) [@flachica](https://community.jenkins.io/u/flachica)\
**Post date:** [April 13, 2022, 9:10am UTC](https://community.jenkins.io/t/how-to-increase-java-memory-ubuntu-server-20-04/2098/1 "2022-04-13T09:10:26Z")

</div>

I have installed the monitoring plugin. In the section of memory used by java I see that the maximum is 2gb when my system allows me 4gb.

I have modified the /etc/default/jenkins file but I think that is not the one I should use as it has no effect.  
Same with this command. sudo `systemctl edit jenkins` and added `Environment="JAVA_ARGS=-Xmx4g -Djava.awt.headless=true"`

Also I modified /etc/init.d/jenkis and set JAVA\_ARG but no effect

What is the correct procedure?

My version of jenkins is the last

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [April 13, 2022, 2:40pm UTC](https://community.jenkins.io/t/how-to-increase-java-memory-ubuntu-server-20-04/2098/2 "2022-04-13T14:40:25Z")

</div>

See the instructions at:

> **[Managing systemd services](https://www.jenkins.io/doc/book/system-administration/systemd-services/)**
>
> Jenkins – an open source automation server which enables developers around the world to reliably build, test, and deploy their software

Good values for the various JVM parameters are offered at

> **[CloudBees Jenkins JVM troubleshooting](https://docs.cloudbees.com/docs/admin-resources/latest/jvm-troubleshooting/)**
>
> This document is intended as a reference for tuning and troubleshooting the Java Virtual Machine within which Jenkins runs, using current best practices as well as a troubleshooting guide for performance issues for Jenkins Administrators.
