canonical / multipass

Multipass orchestrates virtual Ubuntu instances
https://multipass.run
GNU General Public License v3.0
7.54k stars 635 forks source link

idle Multipass memleak ? #3454

Open cryptosven76 opened 3 months ago

cryptosven76 commented 3 months ago

Describe the bug Describe what your problem is. i noticed that since earlier this year multipassd consumes GB's of memory over time even its not used at all

To Reproduce How, and what happened?

  1. simply start multipass when your OS reboots

Expected behavior What did you expect to happen? Not growing in consumption if not used.

Logs Please provide logs from the daemon, see accessing logs on where to find them on your platform.

Additional info

multipass info --all Warning: the --all flag for the info command is deprecated. Please use info with no positional arguments for the same effect. Name: rex101 State: Stopped Snapshots: 0 IPv4: -- Release: -- Image hash: f885a8e8f62a (Ubuntu 22.04 LTS) CPU(s): -- Load: -- Disk usage: -- Memory usage: -- Mounts: --

Additional context multipassd.log

Add any other context about the problem here.

cryptosven76 commented 3 months ago

PID COMMAND %CPU TIME #TH #WQ #PORT MEM PURG CMPRS PGRP PPID STATE BOOSTS %CPU_ME %CPU_OTHRS UID FAULTS COW MSGSENT MSGRECV SYSBSD SYSMACH CSW PAGEINS IDLEW POWE INSTRS CYCLES JETP USER #MRE RPRV VPRV VSIZ KPRV KSHR 789 multipassd 0.4 27:31.49 22 1 81 24G+ 0B 23G 789 1 sleeping *0[1] 0.00000 0.00000 0 3328701+ 253 5156 1787 19511677+ 60661 4758750+ 795 21577 0.4 7419645 5633897 40 root N/A N/A N/A N/A N/A N/A

cryptosven76 commented 3 months ago

you can see it consumed 24G at this time, since the boot of this OS i never started any VM, its in idle state for a week. i see the same behavior on 2 completely independent systems

ricab commented 3 months ago

Hi @cryptosven76,

Thank you for reporting, it looks like we have a memory leak.

ricab commented 3 months ago

@cryptosven76, for the time being, you can try to restart the daemon from time to time. Something like this should do, when your instances are stopped:

sudo launchctl kickstart /Library/LaunchDaemons/com.canonical.multipassd.plist
ricab commented 3 months ago

As a data point, this does not appear to manifest in a snap over a period of ~2h.

cryptosven76 commented 3 months ago

i restarted it yesterday and today i have again 3 GB without using it at all. i wonder if this gets triggered by suspend or sleeps states as the growth seems to be much larger on my macbook than on my mac pro workstation.

ricab commented 3 months ago

Hi @cryptosven76, how are you measuring memory? If you are referring to Virtual Memory, it is normal for multipassd to use 3GB right after being launched. But that is very different from actual RAM being used. Virtual Memory includes a lot of stuff that is not actually loaded, like all the libraries, many of which will be shared by other processes.

I also see multipassd using 3GB of Virtual Memory right after being launched, but the actual Resident Set Size (memory in RAM) is 88MB, and some of that is shared. For comparison, I see a browser with a dozen tabs using 21GB of Virtual Memory, with RSS being 600 MB.

Of course, if the 3GB you see are RSS, that is a problem, especially if you observe it growing over time.

How many VMs do you have when you see this? Do you usually have them running?

kacperk commented 2 months ago

I have similar issue on my Mac. It can grow to sizes that it kills OS (> 24GB) and it happens when there is no VMs running.

ricab commented 2 months ago

Hi @kacperk, sorry you are experiencing this. A few questions to help us understand the issue to better reproduce/debug:

kacperk commented 2 months ago

Observation from today:

  1. From Friday morning (around 72h)
  2. Around 10-20 times + whatever macOS decide to wake up when connencted on charger
  3. Don't know
  4. Yes, around 10MB every 2minutes
  5. Yes
  6. Whatever ActivityMonitor shows
kacperk commented 2 months ago

Screen recording - https://letsbuild.d.pr/i/ueIpt0/2VUO5IPqzF This time machine wasn't suspended, no VMs running - just idle.

ricab commented 2 months ago

Great, thank you @kacperk. That should give us enough to track it down.