Ticket #5159 (closed defect: fixed)

Opened 9 years ago

Last modified 6 years ago

3.0.6 and 3.0.8 memory leak?

Reported by: hoogie76 Owned by:
Priority: major Component: other
Version: VirtualBox 3.0.8 Keywords:
Cc: Guest type: Windows
Host type: Windows


Host is Windows Server 2008 Standard with 4 gig ram. I have one guest that runs Vista 32 and one that runs Windows 7 Pro. Both are allocated 1 gig of ram with 12 mb video. Only one guest is running at a time.

Upon initial startup Memory is consumed normally at a little over 1 gig consumed from the host.

The guests are development environments and run Visual Studio 2008 pro. I can see the memory on the host going down as I load a project, do a build, run a project and publish a project. It nevers seems to get released. I thought memory was pre-allocated so why is it going back to the host for more?

Eventually the host OS starts slowly becoming sluggish and the VM needs to be shutdown.

For Example, with no vm's running. Host has 3137mb free. Start win 7 guest, mem on host goes down to 1627mb. Start Visual studio on guest, host goes to 1597mb free, load project host goes to 1492mb free, run project host goes to 1391mb free, publish project, host to 1224mb free. This pattern continues until host mem is low.

Here's what I found interesting. If I restart the guest os, the memory does not return to the host and the instance of virtual box is never shutdown. If I do a shutdown on the guest, as soon as the virtualbox process terminates the memory is returned to the host. Not sure what else I can supply for info as there are no errors, just symptoms. But it happens on two different guests and two different versions of VirtualBox.


VBox.log.1 Download (64.0 KB) - added by Mikey 8 years ago.
VBox.log.2 Download (48.0 KB) - added by Mikey 8 years ago.
VBox.log.3 Download (64.0 KB) - added by Mikey 8 years ago.

Change History

comment:1 Changed 9 years ago by frank

  • Summary changed from 3.06 and 3.08 memory leak?? to 3.0.6 and 3.0.8 memory leak?

First, VirtualBox does lazy memory allocation, that is, even if you allocated 1GB of memory to the guest, the VM will only consume as much memory as the guest is currently accessing. Linux guest are usually more cooperative than Windows guests. Windows touches the whole physical RAM during the boot process so the guest will use the full amount of RAM you assigned when it finished booting.

So if you start two guests in parallel with 1GB RAM assigned to each of them your host will quickly loose more than 2GB of RAM. Once the memory is assigned to the guest it wouldn't be released anymore until the guest terminates. This is the expected behavior. We plan to improve this in future versions (the guest will be able to return unused memory to the host).

And even if you assign 1GB RAM + 12MB video RAM to your guest, the VMM will require some RAM (some MB) for the maintenance of the VM as well.

So once the guests are completely up and have loaded all applications, the host memory should be more or less stable. But note that the Windows memory usage indicator cannot be trusted. Windows will use a lot of RAM for disk caching and you can imagine that your two guests access a lot of different disk sectors which will induce making Windows use a lot of free memory for disk caching.

comment:2 Changed 9 years ago by sandervl73

  • Status changed from new to closed
  • Resolution set to invalid

That's Windows disk caching grabbing memory. Windows will allocate as much memory for the disk cache as it can. There are ways to limit and monitor the disk cache size. There are several threads on the forum about this subject.

comment:3 Changed 8 years ago by Mikey

  • Status changed from closed to reopened
  • Resolution invalid deleted

Something very similar has happened to me over this weekend just gone.

I left a Windows Server 2008 Standard with 4GB RAM (Host) run with a Windows NT Server 4 (Guest) for about two/three weeks and the used RAM went from 40% at the start of the Guest to 96% after about two/three weeks. I recorded this value last Friday (30th October 2009).

As the Host was still running I thought I could add another Guest (this time a Windows XP Pro) alongside the other Guest (NT Server) and see how it did over the weekend.

I came back in this morning (Monday 2nd November 2009) and I couldn't even ping the Host or get any response from it. I had to do a manual reset because all of the memory was used up.

To me this definitely looks like a memory leak with VirtualBox and not just with Windows disk caching. Also it is definitely an issue for VirtualBox on Windows not just Mac, as that's what what seems to be taken seriously at the moment.

comment:4 Changed 8 years ago by Mikey

Apologies. I forgot to mention that the Host (Windows Server 2008 Standard with 4GB RAM) was 64Bit. And all Guests are 32Bit. Just in case it was of any use.

comment:5 Changed 8 years ago by Mikey

I have now upgraded the VirtualBox on the Host to the latest version, currently at 3.0.10.

Just to confirm, I have ran both Guests (Windows NT Server 4.0 & Windows XP Professional) on the Host (Windows Server 2008 Standard 64Bit).

Once both Guests were running, 70% of the Memory was reported as used by the Windows Server 2008 Resource Monitor. This has steadily climbed to 74% over the last hour. And as I see it, it will continue this upward trend until the Host runs out of Memory.

Just to confirm, this definitely appears to be a Memory Leak in VirtualBox (VB).

comment:6 Changed 8 years ago by sandervl73

The Mac issue is unrelated as the problem was in platform specific drawing code.

Second you don't really give us much information. VBox.log of such a session is essential. Also reporting the amount of memory used by the VirtualBox.exe & VBoxSVC.exe process would be useful.

comment:7 Changed 8 years ago by sandervl73

Use to measure the size of the disk cache too.

comment:8 Changed 8 years ago by hoogie76

I started this thread. Unfortunately in my setup, the memory gadget is telling me that my memory is getting low as well as basic sluggishness of the system.

Looking in task manager on the host does not show where the memory is being used at and the task manager in the guest does not show that it's using the memory. Shutdown of the guest brings my free ram up to 3gig but once the guest is running the memory slowly creeps down until I have to do a shutdown. Restart only of the guest will not release the memory only a shutdown. I have all disk caching on the guest turned off. I have to shutdown several times a day to keep working. Let me know what I can provide to help resolve this.

comment:10 Changed 8 years ago by Mikey

Sorry, I'll try and format better for you:

OK, I have the following for you:

VirtualBox.exe - Commit(KB):53,704 - Working Set(KB):60,024 - Shareable(KB):17,548 - Private(KB):42,492

VirtualBox.exe - Commit(KB):56,696 - Working Set(KB):59,744 - Shareable(KB):17,768 - Private(KB):41,976

VBoxSVC.exe - Commit(KB):10,124 - Working Set(KB):15,708 - Shareable(KB):8,944 - Private(KB):6,768

I have included both VM's statistiscs as well as the VBox Interface.

How do I attach the VBox.log file?

Cache Information: Current Size: 483012 KB Peak Size: 483992 KB

Let me know if you need anything else.

comment:11 Changed 8 years ago by hoogie76

Cacheset on my guest shows my peak cache size as being 48172k. I set it to 1024k to see what affect it has on total memory. I'll keep you updated. Thanks..

comment:12 Changed 8 years ago by Mikey

Hoogie76, my information was for Bandervl73 not you. I wasn't recommending anything, far from it I have no idea what setting the Cache Size to 1024K will do.

If you are aware of this that's OK. I would rather play it safe and inform you just in case...

comment:13 Changed 8 years ago by sandervl73

Mikey: there's an 'Attach File' button at the top.

The same numbers (process memory + cache size) after a number of hours/days would give more insight into where the memory might go.

Changing the 'Working size max' with cacheset should do the trick. I don't know what your current maximum is, but mine is 1 GB on my 4 GB machine.

Changed 8 years ago by Mikey

Changed 8 years ago by Mikey

Changed 8 years ago by Mikey

comment:14 Changed 8 years ago by Mikey

Sandervl73: When you say: "Changing the 'Working size max' with cacheset should do the trick. I don't know what your current maximum is, but mine is 1 GB on my 4 GB machine"

Do you mean the "Working set maximum" in CacheSet? And if so, what value do you have for 1GB in KB?

comment:15 Changed 8 years ago by Mikey

Sandervl73, could you clarify the above for me please as I don't want to trash the Host by making a mistake. Thanks.

comment:16 Changed 8 years ago by sandervl73

Actually my 'Working set maximum' is set to 1 TB for some reason. You can change it to 256*1024 KB (262144) = 256 MB.

comment:17 Changed 8 years ago by Mikey

OK. I have set it to the following:

Working set minimum: 131072 KB Working set minimum: 262144 KB

And even though I've set this, the current size is still at: 292004 KB.

Is that right?

comment:18 Changed 8 years ago by Mikey

Since I last posted the Current Size has now gone up to 350944 KB.

comment:19 Changed 8 years ago by MMMartin

I have encountered a very similar (probably the same) problem with VirtualBox 3.0.12, Vista 32bit host, Win XP SP3 32bit guest and MS Visual Studio 2010 beta. (CPU Intel C2D T5670 without VT-x support)

After starting the VM with 1024 MB RAM assigned, memory usage of the host rises gradually during boot from 1.4GB to 2.5GB. At this time, VirtualBox.exe process uses about 44MB RAM. When VS2010 is started, its logo appears, disappears and the main window opens. Its contents however do not appear, the window just hangs there. At this point, memory usage of the VirtualBox.exe process starts increasing up to about 500MB when VirtualBox crashes because of lack of memory. When the VS2010 window is closed before the crash, memory usage ceases to rise but the memory is not freed.

comment:20 Changed 6 years ago by frank

  • Status changed from reopened to closed
  • Resolution set to fixed

Please reopen if still relevant with VBox 4.1.6.

Note: See TracTickets for help on using tickets.
ContactPrivacy policyTerms of Use