lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
15.26k stars 600 forks source link

Memory is not being freed on VZ #2789

Open okch-codes opened 1 week ago

okch-codes commented 1 week ago

Discussed in https://github.com/lima-vm/lima/discussions/2720

Originally posted by **Muzosh** October 10, 2024 I ran some memory intensive task today and it maxed out at 8GB (which was defined in my config). I was this in MacOS Activity Monitor next to a "Virtual Machine Service for limactl" process. However, once those memory intensive tasks finished, the process stayed at 8GB indefinitely (until colima restart), slowing down my host Mac. Is this intended behavior? I would expect the process to jump down to some idle value (around ~800-1000MB after fresh start).
afbjorklund commented 1 week ago

It is normal for memory that you dedicate to a virtual machine to be locked, the alternative is a feature*.

* called "ballooning" in QEMU, but I am not sure if it is available in Vz yet? Either way, it is not the default.

okch-codes commented 1 week ago

Apparently it's available but it doesn't work.

balajiv113 commented 1 week ago

Yes its a macOS bug. Even docker desktop has the same problem.

Somehow orbstack fixed it with a custom memory management https://orbstack.dev/blog/dynamic-memory

afbjorklund commented 1 week ago

Lima does create a VZVirtioTraditionalMemoryBalloonDeviceConfiguration, but I am not sure if it is used yet?

https://developer.apple.com/documentation/virtualization/vzvirtiotraditionalmemoryballoondevice