Tag Info

Hot answers tagged

23

If your process doesn't spawn more children that consume the most memory, you may use setrlimit function. More common user interface for that is using ulimit command of a shell: $ ulimit -Sv 500000 # Set ~500 mb limit $ pdftoppm ... This will only limit "virtual" memory of your process, taking into account—and limiting—the memory the process being ...


19

A hard limit can only be raised by root (any process can lower it). So it is useful for security: a non-root process cannot overstep a hard limit. But it's inconvenient in that a non-root process can't have a lower limit than its children. A soft limit can be changed by the process at any time. So it's convenient as long as processes cooperate, but no good ...


17

There's some problems with ulimit. Here's a useful read on the topic: Limiting time and memory consumption of a program in Linux, which lead to the timeout tool, which lets you cage a process (and it's forks) by time or memory consumption.


14

maxproc and maxfiles might go unlimited in previous OSX versions, however in Mavericks, they have an artificial maximum value. To increase default maxproc and maxfiles in launchctl, append the following lines to /etc/launchd.conf (create if it does not yet exist): limit maxfiles 16384 16384 limit maxproc 2048 2048 Be aware: those numbers are about as ...


11

No but you should close all active sessions windows. They still remember the old values. Every remote new session or a local secure shell take effect of the limits changes.


10

That is certainly not trivial task that can't be done in userspace. Fortunately, it is possible to do on Linux, using cgroup mechanizm and its blkio controller. Setting up cgroup is somehow distribution specific as it may already be mounted or even used somewhere. Here's general idea, however (assuming you have proper kernel configuration): mount tmpfs ...


9

Important is to know that there are two kinds of limit: hard limit is configurable by root only. This is the highest possible value (limit) for the soft limit. soft limit can be set by ordinary user. This is the actual limit in effect. Solution for a single session In the shell set the soft limit: ulimit -Sn 2048 This example will raise the actual ...


8

ionice from the util-linux does something similar to what you want. It doesn't set absolute IO limits, it sets IO priority and 'niceness' - similar to what nice does for a process' CPU priority. From the man page: ionice - set or get process I/O scheduling class and priority DESCRIPTION This program sets or gets the I/O scheduling class and priority ...


8

A process can change its limits via the setrlimit(2) system call. When you run ulimit -n you should see a number. That's the current limit on number of open file descriptors (which includes files, sockets, pipes, etc) for the process. The ulimit command executed the getrlimit(2) system call to find out what the current value is. Here's the key point: a ...


5

The superuser or any process with the CAP_SYS_ADMIN or CAP_SYS_RESOURCE capabilities are not affected by that limitation, that's not something that can be changed. root can always fork processes. If some software is not trusted, it should not run as root anyway.


5

To make this change pervasive you'll need to add these limits to the entire environment. Changes using the ulimit command are only to the current environment. NOTE: This will have no effect on the root user! Example Edit this file: vi /etc/security/limits.conf and add entries to the file limiting the number of processes (nproc) that a specific user or ...


5

According to the kernel documentation, /proc/sys/file-max is the maximum, total, global number of file descriptors the kernel will allocate before choking. This is the kernel's limit, not your current user's. So you can open 590432, provided you're alone on an idle system (single-user mode, no daemons running). The difference between soft and hard limits is ...


5

There is big difference between them. ulimit -e only set the RLIMIT_NICE, which is a upper bound value to which the process's nice value can be set using setpriority or nice. renice alters the priority of running process. Doing strace: $ cat test.sh #!/bin/bash ulimit -e 19 Then: $ strace ./test.sh ................................................... ...


4

Someone suggested in your hear cgroups. Well, try to seek that direction as it can provide you with: applied to a group of task you choose (thus not system wide but neither per process) the limits are set for the group the limits are static they can enforce hard limit on memory and/or memory+swap Something like that could bring you closer to your goals: ...


4

Actually it can, you just need to run the syscall (which is what the ulimit command does) with CAP_SYS_RESOURCE capability. There are two distinct values for every limit: hard and soft. Soft can be raised even by the user up to the hard limit. The hard limit can only be increased with proper privileges (for some resources it cannot be raised over kernel ...


4

It seems that creating the file /etc/launchd.conf and putting your command inside it should do the trick. If it does not work, you can probably edit or create the /etc/rc.local file and add your command inside it as there is little chance that Apple will ever delete support for limit on the command line. Edit 1: I should have start with that, the ...


4

/etc/security/limits.conf will do exactly what you want. It can limit just a single program name, thus will not impact 'global' settings the way ulimit will. Run the manpage: man limits.conf


4

It says right there in the article: This has no effect on Linux. man setrlimit says it used to work only in ancient versions. The setrlimit man page says: RLIMIT_RSS Specifies the limit (in pages) of the process's resident set (the number of virtual pages resident in RAM). This limit has effect only in Linux 2.4.x, x < ...


3

I see two potential problems. Your limit may not apply to phpuser phpuser may ignore your new limit because it might not use PAM to "log-in", so /etc/security/limits.conf would not apply. See this answer for more details. The system wide limit is reached Your are changing users processes limits. The kernel also has a system wide limit on the number of ...


3

I think the confusion comes from the fact that the underlying system call that ulimit wraps is called setrlimit. excerpt from the ulimit man page The ulimit() function shall control process limits. The process limits that can be controlled by this function include the maximum size of a single file that can be written (this is equivalent to using ...


3

To see the number of file descriptors in use by a running process, run pfiles on the process id. There can be performance impact of raising the number of fd’s available to a process, depending on the software and how it is written. Programs may use the maximum number of fd’s to size data structures such as select(3c) bitmask arrays, or perform operations ...


3

Another way to limit this is to use Linux's control groups. This is especially useful if you want to limit a process's (or group of processes') allocation of physical memory distinctly from virtual memory. For example: $ cgcreate -g memory:/myGroup $ echo $(( 500 * 1024 * 1024 )) > /sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes $ echo $(( 5000 ...


3

Limits are inherited from a parent process to its child processes. Processes running as root can change limits arbitrarily; other processes cannot increase hard limits. Thus the hard limits set by the login process affect all the processes in a session. If you change /etc/security/limits.conf, this will affect all new sessions, and processes in these new ...


3

Let us understand the difference between a process and a thread. As per this link, The typical difference is that threads (of the same process) run in a shared memory space, while processes run in separate memory spaces. Now, we have the pid_max parameter which can be determined as below. cat /proc/sys/kernel/pid_max So the above command returns ...


2

Have seen an issue where we needed to restrict the application's shell to only have 256 file descriptors available. The application was very old and was apparently using the maximum number of fd's and tried to put that number into a variable of type 'unsigned char' which can only hold up to integer 256 (resulting in core dump). So for this particular ...


2

Call setrlimit yourself or use softlimit or something like it.


2

In fact, RLIMIT_NICE allows you to bypass the basic rule that says that "a process can raise its nice value only if owned by root". Demonstration: # ulimit -e 30 # su nobody $ nice -n -10 top You will see that your top process runs with niceness -10. Now if you try nice -n -11 top, it will run with niceness 0, because -11 is not allowed by ...


2

Use pam_limits(8) module and add following two lines to /etc/security/limits.conf: root hard nofile 8192 root soft nofile 8192 This will increase RLIMIT_NOFILE resource limit (both soft and hard) for root to 8192 upon next login.


2

I just added these two lines in my .bash_profile works like a charm ulimit -n 1024 ulimit -u 1024



Only top voted, non community-wiki answers of a minimum length are eligible