VirtualBox using 2x the amount of memory in kernel 5.4 vs kernel 4.19

I used to run my VirtualBox Win10 guest with 6GB RAM (host usage around 7GB+) in kernel 4.19.

Yesterday did an kernel upgrade to 5.4 and my laptop kept hanging (OOM swap AFAIK with Chrome+Firefox). Upon checking it appeared my usual VirtualBox Win10 guest with 6GB RAM was using around 12GB+ instead of the usual 7GB+ in 4.19 kernel.

I double checked with my another WinXP guest with 1GB, it had the same behavior, 4.19 using 1GB+ and 5.4 using 2GB+.

When I rebooted back to 4.19 all back to normal. I've uninstalled the 5.4 ATM, however, do any of you faced this issue?

p/s: My laptop has 16GB RAM, running KDE and nVidia turned off (bbswitch ON when needed).

I'm surprised to the lack of follow-up to this thread, will take a look later if it also happens to me.

Does this behavior reproducible by you too?

Just don't use 5.4 if you're having problems. That kernel is a mess right now and there's no point attempting work arounds when using an alternative kernel is an option and the next update will in all likelyhood make any quick fixes redundant.

How did you determine VirtualBox's memory usage?
There seems to be quite some confusion as ps_memfor example calculates higher memory usage for kernel 5.4. Other tools do not. See this thread for example:

My everyday pattern almost the same, Chrome + Firefox + Skype + Konsole (vim/gcc session) + Vbox VM Win10 (visual studio session), on kernel 4.19 (home) or kernel 4.15 (office due to DisplayLink usage/support). Never trashing.

Once went to 5.4, my laptop trash and hang.

Repeated few times switching kernel 4.19 and 5.4 just to find out why.
if lucky, I was able to:

  1. "free -h" reporting enough (i.e. still having 2GB in the cache/buf and avail) before trash.
  2. ps_mem showing double the amount for 4.19 vs 5.4.
    If unlucky, it just trash+hang b4 I could get a glimpse.

In this case I'm trusting ps_mem.

p/s: all my chrome & firefox have saved pages. I only fired Win10 VM when everything loaded and 'stable'.

I can confirm this with a Win7 guest in ps_mem.
It has 6G allocated but shows up as 6+6=12G in ps_mem.
However I don't think it actually uses 12G.

I think the two values of ps_mem are Resident Mem + Shared Mem (compare with top):

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
231308  user      20   0   10,9g   6,3g   6,1g S   2,7  20,0   1:31.85 VirtualBoxVM

You see the two 6G values, but you also see that the process only uses 20% of memory i.e. around 6.4G on this 32G system.

Here some output of

cat /proc/`pgrep VirtualBoxVM`/status
VmPeak:	11515336 kB
VmSize:	11453540 kB
VmLck:	       0 kB
VmPin:	       0 kB
VmHWM:	 6563536 kB
VmRSS:	 6559320 kB
RssAnon:  125864 kB
RssFile: 6425004 kB
RssShmem:   8452 kB

From ps_mem manpage:

In detail it reports:

              sum (private RAM for program processes) +
              sum (shared RAM for program processes)

The shared RAM is problematic to calculate, and the tool automatically 
selects the most accurate method available for the running kernel.

Forum kindly sponsored by