How to fix VMware eating up all your CPU and slowing down on Linux

Virtual machines are a convenient way to test different operating systems, run legacy applications, or set up a development environment. However, sometimes things can go wrong, and your virtual machine can become unresponsive or slow down significantly. One common issue faced by users is Vmware eating up all their CPU, making the virtual machine practically unusable. Thankfully, there is a straightforward solution to fix this problem on Linux.

When you run virtual machines on Vmware, the vmware-vmx process might eat up 100% of the CPU, which makes the virtual machine unresponsive. However, the host operating system remains relatively unaffected. This issue is usually caused by a conflict between vmware-vmx and the kcompactd0 process, which manages kernel memory.

To fix this issue, you need to run a command that modifies the kernel’s memory management settings. Here are the steps you can follow:

Step 1: Stop the Virtual Machine

First, stop the virtual machine that is causing the issue. You can do this by clicking on the power-off button in the Vmware console or by running the following command:

$ sudo vmware-cmd /path/to/virtual/machine stop hard

Step 2: Modify the Kernel’s Memory Management Settings

Next, open a terminal window and run the following command:

$ sudo sysctl vm.compaction_proactiveness=0

This command changes the kernel’s memory management settings and disables proactive compaction, which is the cause of the issue.

Step 3: Start the Virtual Machine

Once you have modified the kernel’s memory management settings, start the virtual machine again. You should notice a significant improvement in performance, and the vmware-vmx process should no longer consume 100% of the CPU.

Step 4: Make the Changes Permanent

If you are satisfied with the performance of the virtual machine, you can make the changes you made in step 2 permanent. To do this, you need to add the command to the /etc/sysctl.conf file, which is executed during system startup.

To open the /etc/sysctl.conf file, run the following command:

$ sudo gedit /etc/sysctl.conf

This command opens the file in the gedit editor. You can use any editor you prefer.

Add the following line at the end of the file:

# Fix problem where vmware battles with kcompactd0.
vm.compaction_proactiveness=0

Save the file and close the editor.

Finally, restart your Linux system to apply the changes. The command you added to the /etc/sysctl.conf file should run automatically during system startup, ensuring that you do not face the same issue again.

The solution should work on most Linux distributions, including Ubuntu and its derivatives.

Leave a Reply

Your email address will not be published. Required fields are marked *