One of the most common questions that Parallels Desktop users ask us (and probably all other virtual machines) is how to make virtual machines consume less memory. This is asked a huge number of people on the forums and social networks.
Therefore, we always look at which programs and technologies require more memory when a virtual machine is running in PD. And that's what they found.
The “torn” work of the virtual machine, its frequent and tight freeze starts from the moment when too many applications are running on the host that require more memory than the host can physically provide. In addition, the guest OS can start to slow down, if it runs a lot of heavy applications or even just one or two, but very memory-hungry.
Unfortunately, there is no universal advice on maintaining an optimal balance between guest and host memory. Just because people have too different usage scenarios and combinations of programs currently running. For example, someone in a virtual machine wants to run a 3D game, the minimum requirements for which are 2 GB of RAM, while on the host at that moment he doesn’t need anything other than the Parallels Desktop solution itself. And someone, on the contrary, works simultaneously with a browser and several different types of documents on the host OS, and it needs a virtual machine with Windows only for a small application, the analog of which does not exist for Mac. Obviously, in the first case, a person needs to allow the virtual machine to use more host memory (without going beyond the recommended maximum, of course), and in the second case, on the contrary, it would be better to limit the guest OS memory to a minimum. (In Parallels Desktop, you can do this in the top menu of
Virtual Machine , then
Configure , then
General . But first, you need to turn off the virtual machine).
The main thing to remember is that physical memory is not infinite. If a person has the need to constantly use heavy host and guest applications at the same time, and he constantly encounters brakes, he should think about adding a couple of gigabytes of RAM to his Mac. But the main reason for the lack of memory for some users still is that they forget (or do not see the need) to close applications that they no longer need, but minimize or leave their windows hanging in the background. This is especially true of laptop users, the presence of a battery in which allows not to turn off the host between uses. Such applications continue to occupy memory. And if so-called memory leaks also occur in them, this affects the overall speed of the system even worse.
')
Leaks, in addition to demanding applications, also provoke some antiviruses and extensions of various third-party software for browsers. But as it turned out, most of all complaints are caused by Adobe Flash. It is this technology that is uncontrollably and chaotically devouring memory and thus does not free it back. We even calculated: in 99% of cases, when Parallels Desktop users complained of a hang, it was the flash that was to blame, and not a virtual machine at all.
Why it happens? Everybody loves surfing the Internet; many people devote to this case several hours a day. And on the Internet there are a lot of websites with banners that run on a flash (or even there are web resources entirely on a flash, for example, flash games or business card sites of very creative companies). A person launches on his Mac browser (Safari) and starts surfing, opening one site after another in different tabs (and many people like to bring this number to almost fifty).
By the way, this summer, an experiment was run in the Gizmodo tech blog to check how much each open tab consumes (both in Safari and in other browsers), and found out that it is 0.19 Watt. And the opening of 100 tabs, even without any flash, generally reduces the battery life by more than an hour. 
A certain amount of operating system memory is allocated for the browser. If you surf for a long time, the cache naturally overflows, and the data is flushed to the hard disk into a swap file (paging file). And now the surprise: if the browser is only minimized (and not closed completely) and left to hang there for quite a long time (for example, the entire working week), then a huge amount of data will accumulate in it.
In the case of Flash, such memory leaks are very slow and almost invisible to the user. As a result, an average of 3-4 gigabytes accumulates in a few days. Some of the Mac OS data has already been sent to its swap file at this point. The problems begin just at the start of the virtual machine: MacOS is forced to look for a lot of memory for the new process. This leads to the fact that it dumps a huge array of data from the cache into a swap - trying to free up memory for running the virtualization tool and the guest OS. At this point, the virtual machine is trying to read the data needed to start it. Together, this leads to an increase in the number of random disk accesses, and the system begins to slow down.
So look at the Swap used parameter in the Activity Monitor. If the amount of data there is gradually increasing and it is clearly more than 1 GB, then it is likely that some application does not release its memory.
And what to do? But the prevention of this particular problem is very simple - periodically you need to close the browser entirely using Cmd + Q (and not just close the window by clicking on the red stop signal in the upper left corner).
You can also use a few more hints to prevent leaks. For example, to put an ad blocker that eliminates flash banners - there are quite a few of them on the market - from the popular Adblock (which blocks ads before loading it) to PithHelmet and GlimmerBlocker, or something like the ClickToFlash plugin, which Safari blocks Flash by replacing it with static images.
Secondly, it would be good to remove various browser extensions that also cause leaks (for example, antivirus or Skype). In Safari, this is done in the settings window (Safari - Preferences - Extensions), where you can either uninstall the extensions or even block the installation of any add-ons. Just delete a little - you also need to check in the folder ~ / Library / Safari / Extensions, if there is any excess left behind them.
If you have any other tips on how to combat memory leaks, we were waiting for you in the comments.