Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much memory could vm use

Tags:

linux-kernel

I read the document Understanding Virtual Memory and it said one method for changing tunable parameters in the Linux VM was the command:

sysctl -w vm.max_map_count=65535

I want to know what the number 65535 means and how much memory could vm use by the setting.

like image 853
solomon_wzs Avatar asked Jul 27 '12 08:07

solomon_wzs


People also ask

How much memory does a VM use?

A good starting point is to allocate 1GB for 32-bit Windows 7 or later desktops and 2GB for 64-bit Windows 7 or later desktops. If you want to use one of the hardware accelerated graphics features for 3D workloads, VMware recommends 2 virtual CPUs and 4GB of RAM.

How much RAM is too much for VM?

My recommendation: never leave your host with too little RAM. If you have 4 GB on host, don't assign more than 2 GB for a vm. 8 GB or more, I would always leave at least 4 GB to host. My Computer.

How much GB does a virtual machine take?

While VirtualBox itself is very lean (a typical installation will only need about 30 MB of hard disk space), the virtual machines will require fairly huge files on disk to represent their own hard disk storage. So, to install Windows 8, for example, you will need a file that will easily grow to several 10 GB in size.

Can a VM use more memory than allocated?

For each running virtual machine, the system reserves physical RAM for the virtual machine's reservation (if any) and for its virtualization overhead. The total configured memory sizes of all virtual machines may exceed the amount of available physical memory on the host.


Video Answer


3 Answers

From the Linux kernel documentation:

max_map_count:

This file contains the maximum number of memory map areas a process may have. Memory map areas are used as a side-effect of calling malloc, directly by mmap and mprotect, and also when loading shared libraries.

While most applications need less than a thousand maps, certain programs, particularly malloc debuggers, may consume lots of them, e.g., up to one or two maps per allocation.

The default value is 65536.

Bottom line: this setting limits the number of discrete mapped memory areas - on its own it imposes no limit on the size of those areas or on the memory that is usable by a process.

And yes, this:

sysctl -w vm.max_map_count=65535

is just a nicer way of writing this:

echo 65535 > /proc/sys/vm/max_map_count
like image 128
thkala Avatar answered Oct 20 '22 04:10

thkala


echo 'vm.max_map_count=262144' >> /etc/sysctl.conf

sysctl -p
like image 19
田咖啡 Avatar answered Oct 20 '22 03:10

田咖啡


echo "vm.max_map_count=262144" >> /etc/sysctl.conf
sysctl -p

This does not work since we cannot change the configuration file directly. Run the below command.

echo vm.max_map_count=262144 | sudo tee -a /etc/sysctl.conf

But check if vm.max_map_count already exists or not. You can do that using

grep vm.max_map_count /etc/sysctl.conf
like image 6
Meet Luhar Avatar answered Oct 20 '22 05:10

Meet Luhar