Operating System - HP-UX
1755013 Members
3291 Online
108828 Solutions
New Discussion юеВ

Limit process memory usage per process

 
Kevin Moran_1
Occasional Contributor

Limit process memory usage per process

Currently, I have a unix process in production whereby the amount of data being loaded is about to exceed the maxdsiz kernel parameter setting. I really would only like to increase the memory limit for a specific process without enabling for all processes is there a way to do this?
6 REPLIES 6
Colin Topliss
Esteemed Contributor

Re: Limit process memory usage per process

Hmm,

What you'd need to do is increase the limit to cater for the maximum you might want to allocate to your process, and limit the remaining processes on your system to a less amount of memory. Take a look at PRM - it might do what you want (though not quite in the way you expect). Be careful though - if I remember correctly it used to cause problems with Oracle (if the resource limits were reached, PRM used to suspend the offending process - not a good idea if its an Oracle process)!

This is a link to the docs:
http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B8733-90009/B8733-90009_top.html&con=/hpux/onlinedocs/B8733-90009/00/00/11-con.html&toc=/hpux/onlinedocs/B8733-90009/00/00/11-toc.html&searchterms=PRM&queryid=20030925-083022

Col.
Ken Hubnik_2
Honored Contributor

Re: Limit process memory usage per process

Do a man on ulimit. Looks like you can set the process size with this command.
Umapathy S
Honored Contributor

Re: Limit process memory usage per process

Kevin,
Kernel params specify the maximum for anything. You need to increase maxdsiz/maxdsiz_64bit.
But ulimit may help you to restrict other processes from using the max. But this is laborious as only some processes pick up the max. ulimit changes is only available with sh-posix. man sh-posix for more details.
HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Colin Topliss
Esteemed Contributor

Re: Limit process memory usage per process

I don't think you'll find ulimit will allow you to set the resource limits on a per-process basis - its at a user level. Only root can set the limits beyond that defined for the average user.

This is covered on another thread:
http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x0d5e2d88ce9cd711abdc0090277a778c%2C00.html&admit=716493758+1064503332011+28353475

It might do the job if there is no problem with letting other processes under the same user being able to utilise the same memory limit. There's usually more than one way to skin a cat! :-)

Col.
A. Clay Stephenson
Acclaimed Contributor

Re: Limit process memory usage per process

Ulimit applies to a process (and it's children) so that, yes, you can be that granular BUT the problem is that you are not going to be able to use ulimit to exceed maxdsiz. You really have to turn the question around and first enable a large maxdsiz -- which opens up the value for everybody and then restrict the memory usage via ulimit -Sd xxxxxx to limit the memory usage. You could set a lower ulimit in /etc/profile via ulimit -Sd xxxxxx and then allow the individual process to set ulimit -Sd to a higher value then the setting in /etc/profile.

If it ain't broke, I can fix that.
Colin Topliss
Esteemed Contributor

Re: Limit process memory usage per process

Thats a good way to do it. The only thing I can think of that will put a spanner in the works is that we don't know anything about the process and how it is started. If its one spawned from within another application (such as Oracle for example) then it becomes a slightly different problem. You could potentially have to apply the ulimit settings to the parent of the process being initiated (so the child inherits the limits). That parent may be able to initiate more than one type of process (some of which may not be required to use the upper limit). You may not have the ability to have the process itself change its ulimit.
If its a process started manually from a user account, then your method is much better than PRM (which I have reservations about anyway).