Solved

How do i could limit memory use to an service?

Posted on 2010-09-10
5
1,496 Views
Last Modified: 2013-12-16
How do i could limit memory use to an service?.

%MEM of service/ process "drwebd.real" in my linux box its always  around 85-90%...

  PID USER      PR  NI  VIRT  RES  SHR S %CPU     %MEM    TIME+  COMMAND
16097 drweb     16   0 1947m 1.8g  440 D  5.6      90.0   1:03.10 drwebd.real


thanks
0
Comment
Question by:VMWARE
  • 3
  • 2
5 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 500 total points
Comment Utility
Hi,
you could try to set the "memory" ulimit for the user "drweb" before starting "drwebd.real". Create a script, if needed, containing the "ulimit" command and the call to "drwebd.real".
As an alternative you could set this value permanently and globally for user "drweb" in /etc/security/limits.conf.
Display all settings with
ulimit -a
and change the "memory" limit by issuing
ulimit -m new_value_in_kilobytes
wmp
0
 

Author Comment

by:VMWARE
Comment Utility
Hello woolmilkporc,

How do I for  that user "drweb", was limited to 75% of maximum memory, using the second option?

Thanks
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
To avoid a possible misunderstanding - there is no limit controlling total memory available to all processes belonging to one user!
The virtual memory limit is enforced per process only!
Anyway, to limit the processes started by drweb to "see" only 75% of memory each, add to /etc/security/limits.conf (as root)
drweb     hard     as    (75%_of_memory_in_kilobytes)
drweb     soft      as    (75%_of_memory_in_kilobytes)
This sets both the initial value (soft) as well as the limit up to which the user can change this value by means of "ulimit (hard).
 Remeber to logout and re-login as drweb, once this setting has been changed by root in limits.conf!
0
 

Accepted Solution

by:
VMWARE earned 0 total points
Comment Utility
Hello woolmilkporc,

could be something of that sort?

drweb           hard                    1572864 (75% of 2GB)
drweb           soft                    1572864

after, its enought restart the service drwebd as root?
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Nearly!

drweb           hard            as      1572864
drweb           soft              as      1572864

"as" means "address space" and has to appear literally!

And the first column indicates the userid which is the owner of the process! So "restart the service drwebd as root" sounds a bit strange, since the "ps" output you posted in your question indicates "drweb" as the owner of "drwebd.real"!

The "normal" procedure would consist in starting the process as user "drweb" after a fresh login.

OK, it might be that you actually start drwebd as root and the script/program involved would do a switch to the "drweb" userid. If this is the case you can only try out if it works, because I don't know whether you OS will indeed respect the limit settings of the target userid in such a case - but I think it will.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now