Are you confident that you’ve made the correct edits to the Jenkins service unit?
On my Ubuntu 22.04 machine, I installed Jenkins 2.361.1 using the Ubuntu installation instructions. I configured Jenkins and confirmed that top
showed that it was using 2 GB of heap. I edited the systemctl override with systemctl edit jenkins
and inserted the following changes
[Unit]
Description=Jenkins ubuntu-22-a
[Service]
# Arguments for the Jenkins JVM
Environment="JAVA_OPTS=-Xmx512M -Djava.awt.headless=true"
I used systemctl daemon-reload
to assure that the new configuration was read, then used systemctl restart jenkins
to restart the Jenkins controller.
After the restart, top
reported that Jenkins was using less than 512M.