Skip to content

Configuring memory allocation

Configuring memory allocation

To configure memory allocation, you must tune the memory_limit attributes of high and max for the QM partition.

The max value represents the maximum limit for memory use in the QM partition. If QM processes attempt to exceed the max limit, the Out of Memory (OOM) killer is initiated. The high value is the memory threshold that the kernel tries not to exceed. If QM processes reach the high limit, the kernel will proactively release memory.

Prerequisites

Procedure

  • In your manifest file, configure the memory_limit attributes max and high to 40% and 35%, respectively:

    console title="Example memory_limit configuration" --8<-- "demos/container_qm_network/container_qm_network.aib.yml:27:30"

Verification

  1. Build the image:

    console title="Example Automotive Image Builder command" $ automotive-image-builder build \ --distro autosd9 \ --target qemu \ --mode image \ --export qcow2 \ <my_manifest>.aib.yml \ <my_image>.qcow2

  2. Run the image:

    console title="Example Automotive Image Runner command" $ automotive-image-runner <my_image>.qcow2

  3. After the image starts, log in as root using the password password.

  4. Use the systemctl show command to display the MemoryMax value generated by the max option you set in your manifest:

    console title="Verify QM partition MemoryMax" [root@localhost ~]# systemctl show qm | grep MemoryMax MemoryMax=823468032

  5. Use the systemctl show command to display the MemoryHigh value generated by the high option you set in your manifest:

    console title="Verify QM partition MemoryHigh" [root@localhost ~]# systemctl show qm | grep MemoryHigh MemoryHigh=720535552

  6. Review the contents of the drop-in file generated by your manifest using the cat command:

    ```console title="Show drop-in configuration file contents" [root@localhost ~]# cat /usr/share/containers/systemd/qm.container.d/10-automotive.conf [Service] MemoryMax=40% MemoryHigh=35% CPUWeight=idle

    [Container]

    ```

Additional resources