LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how does ulimit work (https://www.linuxquestions.org/questions/linux-software-2/how-does-ulimit-work-927100/)

wastingtime 02-02-2012 01:58 AM

how does ulimit work
 
$ ulimit -m 150000 -v 500000
$ /usr/lib/thunderbird-9.0/thunderbird-bin

However

$ top
top - 23:46:50 up 4 days, 9:17, 6 users, load average: 0.33, 0.40, 0.43
Tasks: 129 total, 1 running, 128 sleeping, 0 stopped, 0 zombie
Cpu(s): 10.2%us, 2.8%sy, 0.0%ni, 87.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1024220k total, 920192k used, 104028k free, 4176k buffers
Swap: 2096444k total, 0k used, 2096444k free, 385832k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10545 user 1 0 475m 154m 31m S 0.0 15.4 0:30.89 firefox
9183 user 1 0 463m 168m 19m S 0.0 16.9 1:43.64 thunderbird-bin

How come thunderhog consumes more resident memory that ulimit allows?

jv2112 02-02-2012 04:30 AM

man ulimit


Quote:

DESCRIPTION
The ulimit utility shall set or report the file-size writing limit
imposed on files written by the shell and its child processes (files of
any size may be read). Only a process with appropriate privileges can
increase the limit.


------------------------------------------------------

APPLICATION USAGE
Since ulimit affects the current shell execution environment, it is
always provided as a shell regular built-in. If it is called in a sepa‐
rate utility execution environment, such as one of the following:

nohup ulimit -f 10000
env ulimit 10000

it does not affect the file size limit of the caller's environment.






wastingtime 02-02-2012 05:46 AM

Yeah, I know about man ulimit.

How come thunderbird consumes more resident memory than what ulimit allows?

jv2112 02-03-2012 04:34 AM

I just ran the same test on my system and thunderbird crashed because of lack of memmory. It appears to need it.

If you were doing all in the same shell I can only guess it is a permission issue.

Code:

[joe@Tux-Box ~]$ thunderbird
Xlib:  extension "RANDR" missing on display ":0.0".
ReminderFox  clh(1)  {rmFx_cmdLine: [xpconnect wrapped nsICommandLine]}
out of memory
Segmentation fault


wastingtime 02-03-2012 09:35 AM

Yep, I speculate that ReimderFox extension, which I don't have installed, wants to gobble even more memory. This is so poorly designed it cannot handle out of memory error.

In your case ulimit seems to have done it's job though. My question is opposite: why thunderbird could allocate more memory that ulimit should have let it?

mpb 10-22-2016 10:26 PM

Quote:

How come thunderhog consumes more resident memory that ulimit allows?
"ulimit -m" sets RLIMIT_RSS. Linux does not enforce RLIMIT_RSS.

From man setrlimit:

Code:

      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 < 30, and there affects only calls
              to madvise(2) specifying MADV_WILLNEED.

Instead consider "ulimit -v" which sets RLIMIT_AS.

Code:

      RLIMIT_AS
              The maximum size of the process's virtual memory (address space)
              in bytes.  This limit  affects  calls  to  brk(2),  mmap(2)  and
              mremap(2),  which fail with the error ENOMEM upon exceeding this
              limit.  Also automatic stack expansion will fail (and generate a
              SIGSEGV  that  kills  the process if no alternate stack has been
              made available via sigaltstack(2)).  Since the value is a  long,
              on  machines  with  a 32-bit long either this limit is at most 2
              GiB, or this resource is unlimited.

Also, the man page for ulimit is not really relevant. It refers to the (obsolete?) ulimit "utility".

http://pubs.opengroup.org/onlinepubs...es/ulimit.html

The ulimit utility is not present on my Ubuntu Linux system. Instead, ulimit is typically a shell builtin command, and is documented in each shell's manpage.


All times are GMT -5. The time now is 12:46 AM.