VMware Communities
Trideep_Gogoi
Contributor
Contributor

VMWARE Fusion not releasing memory after quitting

I noticed a strange memory issue with VMware Fusion Beta 3.

I have a Macbook Pro core Duo 2.0 MHz with 2GB ram and 80GB HDD

On a fresh start activity monitor shows that i have the following memory characteristics.

Wired: 123.34 MB; Active: 173.07MB; Inactive: 187.74MB; Used: 485MB; Free 1.53 GB; VM Size(OS x Page file) 5.71 GB

After stating VMware i restore my Windows appliance that has been assigned 800MB. It takes a bit of restore and ends up taking 856MB, which is perfectly fine as I am running Visual Studio for testing purposes. the VMruns very very fast with no lags and the performance on OS X is also very very good

So while running VMware my Memory characteristics are as follows

Wired: 260.23MB; Active: 800.62 MB; Inactive 379.54MB; Used 1.37GB; Free 636MB; VM ize (OS x page file) : 7.16 GB and VMware-vmx taking up 820MB

Heres the strange thing after i quit VMware (during quit it also suspends the virtual appliance) i get the following memory characteristics.

Active 129.77MB; Active: 864.38MB; Inactive: 341.79MB; Used 1.30 GB; Free 712MB; VM Size(OS x pagefile): 5.71GB

Where did my memory go? The running programs do not add up to the abnormal useage. It seems like once vmware quits it takes the memory with it. Performance issues after vmware quits is not an issue os x is very very snappy like always. But i never seem to get that memory back. If i use a different program like Garageband which takes up about 600MB however right after i quit it i gives me all the memory back.

If I relaunch vmware and open the appliance again it restores very very fast. this is even if i have been doing a lot of other things on my computer. If i continue to keep launching and quitting vmware fusion the "free" memory keeps decreasing and the "Active" keeps growing till i hit under 100Mb free and 1.8GB active after which the system becomes unusable.However Launching VMware is now very very fast and the VM runs very very good.

I understanding is this: somehow everyone the Vm launches all the stuff is being cached in RAM thus subsequent launches are fast. but after quitting the cache is no given back.

Reply
0 Kudos
40 Replies
Trideep_Gogoi
Contributor
Contributor

As a follow up I tried it on my Macbook and my roommate's Imac and all three computers have the same issue.

Reply
0 Kudos
czbri
Contributor
Contributor

Sounds like how OSX does memory management to me. From OSX's perspective, why free up the memory when you could possibly launch another VMware application. I believe windows does the same thing for memory management. It obviously allocated into "inactive memory". It doesnt mean its not available, its just inactive.

A good test of this is to do the same with Garageband and see if Garageband gives back the memory of if its still inactive. Maybe even try it with another big app.

Reply
0 Kudos
admin
Immortal
Immortal

A good test of this is to do the same with Garageband and see if Garageband gives back the memory of if its still inactive. Maybe even try it with another big app.

Trideep's original post already covered this Smiley Happy "If i use a different program like Garageband which takes up about 600MB however right after i quit it i gives me all the memory back."

Sounds like how OSX does memory management to me. From OSX's perspective, why free up the memory when you could possibly launch another VMware application.

Yes, except that once another app needs the RAM taken up by the cache, the memory should be able to be used by the other app.

If i continue to keep launching and quitting vmware fusion the "free" memory keeps decreasing and the "Active" keeps growing till i hit under 100Mb free and 1.8GB active after which the system becomes unusable.

This worries me. If things were working properly, I'd expect there to be some initial slowness as the cached VMware data is replaced, but once that's done it should be normal. I'll try reproducing it later. Trideep, you should file a bug[/url] about this.

Reply
0 Kudos
Bob_Zimmerman
Expert
Expert

A good test of this is to do the same with

Garageband and see if Garageband gives back the

memory of if its still inactive. Maybe even try it

with another big app.

Trideep's original post already covered this Smiley Happy "If i

use a different program like Garageband which takes

up about 600MB however right after i quit it i gives

me all the memory back."

Sounds like how OSX does memory management to me.

From OSX's perspective, why free up the memory when

you could possibly launch another VMware

application.

Yes, except that once another app needs the RAM taken

up by the cache, the memory should be able to be used

by the other app.

That would be normal memory management under OS X, yes. Normally, the memory would remain in use but be marked "inactive", which means it's cache that other apps can overwrite. The Activity Monitor can take quite a while to update sometimes, though. I'd give it about 30 seconds, after which if the inactive memory doesn't increase sharply and the active decrease, there's something wrong.

Basically, a healthy OS X system should hover around 50 MB of free memory after it's been running for a few days. Active and inactive should be where most of your changes are.

This problem does not appear on my system. Maybe it's something weird with the OP's install of VMware? I normally quit by suspending all of my VMs by hand. I then close their windows and use Command-Q to quit.

Reply
0 Kudos
Trideep_Gogoi
Contributor
Contributor

All my tests were performed on different machines but with the same appliance. maybe thats the problem. As i said After VM quits subsequent launches are very fast. But im no certain that os x is doing any caching. In order o recreate the problem or situation u have to really use the VM. I can get VMware to take up 800 to 1GB of memory easily during use. As i said performance while VMware is not an issue. Only subsequent launches cause the Active memory to rise. And as i said in the post the memory usage does not change at all after quitting VMware.

I will try installing the vm tomorrow.

Reply
0 Kudos
img47
Contributor
Contributor

I have even worse problem - Active memory is not released AT ALL after quitting VMware. So from 154 MB it went up to 856 MB when running VMware and then stayed that way after quitting. Only OS X restart helps.

Reply
0 Kudos
admin
Immortal
Immortal

Sorry for the dumb question, but how are you making sure that the memory is marked Active? Can you get a screenshot of Activity Monitor's System Memory tab before running Fusion and after quitting it?

Reply
0 Kudos
Stefsun
Contributor
Contributor

The guys are right. I have 3 GB of RAM.

I start Fusion and I have 1.6 GB left. I suspend the VM, quit Fusion, and the available memory is no more than 1.7.

But listen to this, if I reopen Fusion, Shutdown Windows, and quit Fusion again, then I have my usual 2.6 GB free again.

And I am using the unbuffered hard disk switch.

In the log I also notice that only when I shutdown Windows before I quit Fusion it releases virtual memory pages.

Jun 24 14:59:14 StefMac kernel[0]: vmmon: Cleaned up 67614 virtual main memory pages from VM 0x7a86004.

Jun 24 14:59:14 StefMac kernel[0]: vmmon: Cleaned up 4222 monitor anonymous pages from VM 0x7a86004.

Hope that helps

Message was edited by:

Stefsun

Reply
0 Kudos
img47
Contributor
Contributor

Interesting. I was also suspending the virtual machine (not shutting down).

Reply
0 Kudos
img47
Contributor
Contributor

etung - I cannot post screenshots right now, as I have uninstalled Fusion, waiting for the new release or final version. I am checking Active memory both in Activity Monitor and iStat Pro 4.1, waiting several minutes after quitting Fusion.

Reply
0 Kudos
fuzzy-wan
Enthusiast
Enthusiast

But listen to this, if I reopen Fusion, Shutdown

Windows, and quit Fusion again, then I have my usual

2.6 GB free again.

I've noticed how I never get much of my "free" RAM back after closing down the VM (via suspend), but haven't done a careful study of it.

But you gave me an idea: Instead of suspending the VM, I used the Windows Hibernate option to shut it down from the inside. Big huge slice of green (free) RAM showed up in Activity Monitor, and more importantly, Active RAM is only 460MB (out of 2GB). Repeating the process (run VM, Hibernate) leads to the same results -- no massive increase in Active RAM. Inactive is about the same either way, roughly 560MB on my system.

And when the Active does[/b] start to eat my system's lunch after a few too many suspends, the Hibernate maneuver puts everything back to rights.

Knowing that I can get the memory back makes me feel a lot more secure. Whew.

Reply
0 Kudos
ksc
VMware Employee
VMware Employee

The large "active" size is expected, and I'll echo Bob Zimmerman's comment that you need to give the statistics more time to settle. (10-20 minutes at least). We're not actually leaking memory; instead, OSX is taking extra time to write the memory we've changed back to disk. The key insight here is that "active" includes memory that is no longer in use, but OSX has not yet written to disk.

If you've got a 2GB VM running, then the OS has to write up to 2GB of data out to disk (in your case, it looks like ~700MB of data actually has to go out). This operation can take several minutes - OSX does it in the background after the VM turns off. We have code that makes this occur as fast as possible ... but with data sizes this large, it takes time.

"VM size (OS x page file)" is the most accurate measure of total memory in use. In other words, Fusion tells the OS memory is free right away; the OS takes longer to make it inactive.

Reply
0 Kudos
Stefsun
Contributor
Contributor

Good find, it works perfectly, thanks. I didn't even know hibernate worked, never did with Parallels.

Reply
0 Kudos
Stefsun
Contributor
Contributor

ksc, in my case it never gives it back, even after 2 hours, unless I shutdown Windows before quitting Fusion, or restart the system all together.

I think that by just suspending the VM and quitting Fusion, Fusion does not release the memory at all.

By hibernating or shutting down the VM, Fusion releases the RAM back to the system.

Reply
0 Kudos
ksc
VMware Employee
VMware Employee

My above post talks about how it takes considerable time for OSX to clean up after the memory a VM uses ... I'll expand on one more detail (suspend vs. power off).

In the suspend case, we have to keep the in-use memory around - this is the huge file OSX has to write back to disk after the VM suspends, which takes minutes. (If you want to see how long, look for a administrator-owned process called "vmware-vmx" - when it finally closes, all the data is finally written back).

In the power-off case (Windows hibernate is power-off), we do some special tricks to tell the OS we don't need all the memory written back to disk (namely, we delete the file so there is nowhere to write it back to!). So OSX can reclaim this memory right away.

Again - this isn't a memory leak. There is a significant delay between closing a VM and OSX reclaiming the memory that isn't obvious.

Reply
0 Kudos
ksc
VMware Employee
VMware Employee

ksc, in my case it never gives it back, even after 2

hours, unless I shutdown Windows before quitting

Fusion, or restart the system all together.

I think that by just suspending the VM and quitting

Fusion, Fusion does not release the memory at all.

By hibernating or shutting down the VM, Fusion

releases the RAM back to the system.

Try another experiment - after suspending the VM, start up a bunch of very memory-hungry apps, and use them for a while. (Garageband encoding music files, copy some large files around your hard drive...). Then close them. Afterwards, memory usage should be back to normal. The other apps put pressure on OSX to reclaim memory ... OSX has no reason to move memory active->inactive unless another app is using a lot of memory.

Reply
0 Kudos
ksc
VMware Employee
VMware Employee

I should also point out that, due to the way OSes manage processes, the ONLY memory that an app can prevent from eventually being reclaimed by the OS is "wired" memory. (Where "eventually" means a combination of "needed by other apps" and "has been written to disk"). Everything else, OSX will eventually take back, and no application can prevent it from occurring.

If you see a leak in "wired" memory, I'll get concerned Smiley Happy

Reply
0 Kudos
Stefsun
Contributor
Contributor

I agree with you 100%, although when suspending the VM I end up with 1.6 GB of free RAM instead of 2.4 I get when hibernating or shutting down the VM prior to quitting Fusion.

Slowly slowly I can reclaim the memory, either by -like you proposed- opening up a big program or by running the weekly clean-up through Macaroni, but if I don't, I can spend hours with 1.6 GB free.

The problem here is that I usually quit Fusion when I want to run something heavy, usually Illustrator and Photoshop since I do work in an advertising agency, and that's where my main problem is with active and inactive memory, the pageouts begin too fast, before the Fusion mechanism has time to release the memory, or X to realize that is free. If I shutdown or hibernate instead, I have all my memory back from Fusion, with no pageouts. So in the long run, Fusion should release all the memory regardless of what the VM does, I don't care about an extra 10 seconds in relauncing the VM, but I do care about the pageouts.

No I don't notice a leak in wired memory, rest assured you would be the first to know if I did. Smiley Happy

Reply
0 Kudos
img47
Contributor
Contributor

I am slightly confused after reading those contradicting answers:

\- should it release Active memory after few minutes (and it does not, because there is a bug) ?

\- it is by design not releasing Active memory at all when suspending guest OS (and everything is supposedly OK) ?

Reply
0 Kudos