Limit RAM Usages


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Limit RAM Usages
# 8  
Old 04-26-2012
Shirish,

The amount of RAM set aside by min_free_kbytes cannot be used for processes, cache or buffers. It's "reserved" for use by new processes that are starting up. By reserving it, you're effectively setting it aside so the system can't use it. So, if you had a system with 1GB of RAM and you set min_free_kbytes to 750MB, the system would behave as though it had only 250MB to work with.

The simplest way is to boot the system, let it run with the application started but with no real load. Use "free" to see how much memory the system is currently using, not including cache and buffers.

For example, here is a system with 2GB of RAM. It happens to be a Fedora 16 VM, but the virtual memory model is the same:

Code:
# cat /proc/sys/vm/min_free_kbytes
45056
# free -k
             total       used       free     shared    buffers     cached
Mem:       2053048    1524288     528760          0     112112     895452
-/+ buffers/cache:     516724    1536324
Swap:      4128764          0    4128764
 
# sar -B 10 1
Linux 3.1.0-7.fc16.x86_64 (fed16) 04/26/2012 _x86_64_ (2 CPU)
10:27:14 AM pgpgin/s pgpgout/s fault/s majflt/s pgfree/s pgscank/s pgscand/s pgsteal/s %vmeff
10:27:14 AM  pgpgin/s pgpgout/s   fault/s  majflt/s  pgfree/s pgscank/s pgscand/s pgsteal/s    %vmeff
10:27:24 AM      0.00      0.00      6.00      0.00     19.40      0.00      0.00      0.00      0.00
Average:         0.00      0.00      6.00      0.00     19.40      0.00      0.00      0.00      0.00

So, it's currently using about 516MB for processes and has about 1.5GB unused. There is no active paging activity. The min_free_bytes parameter is set to about 45MB. If we increase min_free_kbytes to 1500000 (1.5GB), then the system is forced to reserve that 1.5GB for new processes and acts as though it only has 500MB of RAM. If we start to stress the system, it can't use the 1.5GB you've told it to reserve, so it has no choice but to start actively paging to the swap area to find the memory to continue to run.

Using this method, you can put any system into a condition where it thinks it's almost out of memory and needs to start paging.

If you reserve so much memory that the system doesn't have enough to run, it will start paging immediately without any load. Here's what happens if we reserve 1.7GB:
Code:
# echo 1700000 >/proc/sys/vm/min_free_kbytes
# cat /proc/sys/vm/min_free_kbytes
1700000
# free -k
             total       used       free     shared    buffers     cached
Mem:       2053048     349968    1703080          0       1332      87004
-/+ buffers/cache:     261632    1791416
Swap:      4128764     265864    3862900

I pushed this system to use 256MB of the swap space. It immediately started actively paging and performance is horrible. Very slow response to commands. You can see the active paging activity:

Code:
# sar -B 10 1
Linux 3.1.0-7.fc16.x86_64 (fed16)       04/26/2012      _x86_64_        (2 CPU)
10:29:14 AM  pgpgin/s pgpgout/s   fault/s  majflt/s  pgfree/s pgscank/s pgscand/s pgsteal/s    %vmeff
10:29:24 AM   4176.62    815.18    772.33    220.88   2023.98   3435.26      0.00   1992.91     58.01
Average:      4176.62    815.18    772.33    220.88   2023.98   3435.26      0.00   1992.91     58.01

If we return min_free_bytes to it's inital value, the system quickly returns to normal:
Code:
# echo 45000 >/proc/sys/vm/min_free_kbytes
# sar -B 10 1
Linux 3.1.0-7.fc16.x86_64 (fed16)       04/26/2012      _x86_64_        (2 CPU)
10:33:27 AM  pgpgin/s pgpgout/s   fault/s  majflt/s  pgfree/s pgscank/s pgscand/s pgsteal/s    %vmeff
10:33:37 AM      0.00      0.00      2.50      0.00      5.60      0.00      0.00      0.00      0.00
Average:         0.00      0.00      2.50      0.00      5.60      0.00      0.00      0.00      0.00
# free
             total       used       free     shared    buffers     cached
Mem:       2053048     358248    1694800          0       5044     149616
-/+ buffers/cache:     203588    1849460
Swap:      4128764     375632    3753132

Notice that the last free command shows 375MB of the swap area still used, which is OK, since it's static usage. The system will go get those pages out of swap if and when it needs them. The important point is that there isn't any active paging going on anymore.

See how this works?

Last edited by sds9985; 04-26-2012 at 11:46 AM..
# 9  
Old 04-28-2012
Thanks a LOT !!! It;s clear my need ...

--Shirish Shukla
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Cybersecurity

Limit CPU and RAM utilization for new user in RedHat

We have a system with 4 Xeon Processors each with 10 cores, total 512 GB RAM and 10 TB Hard Drive. we want to create multiple user accounts with different resource limitations as : User 1: RAM : 50GB, PROCESSOR: 10 Cores , User folder in home directory of 10GB space. User 2: RAM :... (5 Replies)
Discussion started by: vaibhavvsk
5 Replies

2. Shell Programming and Scripting

help me for Perl script for tool usages

Hi, How to do Perl script for floating license usages metric. Anyone help me out this issue? Regards, Ram. (0 Replies)
Discussion started by: ramanthan
0 Replies

3. Red Hat

Physical RAM

Hi, I have a server (BL460c) with 32G of physical RAM. It currently only uses approx 5% its capacity but will use more (not sure how much more) pending the launch of further applications. If I need to build another node of similar functionality should I consider downgrading the physical... (2 Replies)
Discussion started by: Duffs22
2 Replies

4. Solaris

Limit: stacksize: Can't remove limit

Hi all, I'm using to Solaris machine. When I run a simple script this messenger come out:"limit: stacksize: Can't remove limit". Any one know the way to resolve this problem without reboot the machine? Thanks in advance. (3 Replies)
Discussion started by: Diabolist9
3 Replies

5. Solaris

How get memory and cpu usages of user's processes?

I have the processes (100+) by the oracle id and I'd to get the summarized view of the oracle processes' usage of the memory and the cpu. top would give me some, but not all. Thanks (3 Replies)
Discussion started by: iwmi
3 Replies

6. AIX

[AIX] usages of lint for .cpp file?

Hi , I Want to apply AIX lint to my source code which all are *.cpp/*.h >lint test.cpp lint: 1286-332 File test.cpp must have a .c, .C or .ln extension. It is ignored. lint: 1286-334 There are no files to process. I am getting above error. -Ashok (3 Replies)
Discussion started by: ashokd001
3 Replies

7. Red Hat

red hat Linux 5.0 is detecting 3gb ram but physical ram is 16gb

Hi, On server 64bit Hw Arch , Linux 5.0(32bit) is installed it is showing only 3gb of ram though physical is 16gb can u give me idea why? (4 Replies)
Discussion started by: manoj.solaris
4 Replies

8. Linux

Built in ram limit for 64 bit

Hey all, I have been thinking about getting a new computer, and the motherboard I am looking at is capable of holding up to 8 Gb of ram. Now it appears as though for 32 bit linux, in order to use more than 4 Gb of ram, you had to enable a certain option in the kernel, but if I remember... (2 Replies)
Discussion started by: kermit
2 Replies

9. Solaris

Usages of Array's (Important please)

;) Hi friends, any one please help me. I want to store some job names into an array and also I want extract these names on different timings for scheduling. Please give me some idea. your's loving LOVE :p (1 Reply)
Discussion started by: Love
1 Replies

10. Programming

getting RAM size

Sir, How can i get the RAM size .Is there is any predefined function ..Howsir??? Thanks In advance, ArunKumar (6 Replies)
Discussion started by: arunkumar_mca
6 Replies
Login or Register to Ask a Question