This seems to be https://github.com/openjdk/jdk/pull/23811 fixed so far
only in Java 25.

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux-meta-hwe-6.14 in Ubuntu.
https://bugs.launchpad.net/bugs/2117446

Title:
  6.14.0 (24.04 HWE) breaks Java heap ergonomics in container

Status in linux-meta-hwe-6.14 package in Ubuntu:
  New

Bug description:
  Given this `Vagrantfile`

  ```
  Vagrant.configure("2") do |config|
    config.vm.box = "boxen/ubuntu-24.04"
    config.vm.box_version = "2025.04.02.21"
    config.vm.provider "virtualbox" do |vb|
       vb.memory = "4096"
    end
  end
  ```

  run `vagrant up` and when ready, `vagrant ssh`. Now install Docker as
  per https://docs.docker.com/engine/install/ubuntu/ and also `sudo
  usermod -aG docker $USER` and `sudo apt dist-upgrade` and then log
  out, `vagrant halt`, `vagrant up`, `vagrant ssh` again to log back in
  with the freshest 6.8.0 (general) kernel and running in the `docker`
  group. Run

  ```
  docker run -m 1GB eclipse-temurin java -XshowSettings:vm 
-XX:MaxRAMPercentage=50 -version
  ```

  You should see something like

  ```
      Max. Heap Size (Estimated): 494.94M
  ```

  i.e., ½ of 1Gb ~ 500m, as expected.

  Now

  ```
  sudo apt-get install --install-recommends linux-generic-hwe-24.04
  ```

  and reboot, so as to be running 6.14.0. Run the Docker/Java command
  again and you will get

  ```
      Max. Heap Size (Estimated): 1.90G
  ```

  which is incorrect: the heap size is being taken from the physical RAM
  of the VM, not the resources allocated to the container.

  ----

  Originally observed in my 24.04.2 desktop machine, when running
  https://github.com/kubernetes-sigs/kind and specifying pods with
  specific memory limits which run Java without an explicit heap size (a
  common setup which ensures the JVM will take good advantage of
  whatever container limits you offer it). Until a few days ago, this
  worked fine; on 2025-07-18 I apparently accepted a kernel upgrade to
  6.14.0 from 6.8.0, and now these pods frequently crash with
  `OOMKilled` status unless I manually set an explicit heap size smaller
  than the container limit, such as with `-Xmx2g`. Can be seen using
  Kind (0.29.0) though the setup is more complex than with Docker:

  ```
  kubectl run --restart=Never --rm -ti --image eclipse-temurin 
--overrides='[{"op":"replace", "path":"/spec/containers/0/resources/limits", 
"value":{"memory": "2048Mi"}}]' --override-type=json java$RANDOM -- java 
-XshowSettings:vm -version | fgrep -i heap
  ```

  now prints

  ```
  Max. Heap Size (Estimated): 15.62G
  ```

  which seems to be taking ¼ of my 64Gb physical RAM, whereas running
  the same command against GKE (1.32) in the cloud

  ```
  Max. Heap Size (Estimated): 512.00M
  ```

  as expected.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux-meta-hwe-6.14/+bug/2117446/+subscriptions


-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to