Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #236899

Re: Limit memory consumption of an ad hoc process

From Greg Wooledge <greg@wooledge.org>
Newsgroups linux.debian.user
Subject Re: Limit memory consumption of an ad hoc process
Date 2021-07-05 14:00 +0200
Message-ID <Cxvqx-7ee-7@gated-at.bofh.it> (permalink)
References <CxnCF-2bG-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jul 05, 2021 at 10:15:19AM +0700, Victor Sudakov wrote:
> FreeBSD has a simple way to run some ad-hoc program with memory limits:
> 
> $ limits -m 2G ./mytest
>   memoryuse             2097152 kB
>   vmemoryuse           infinity kB
> $ limits -m 1G ./mytest
>   memoryuse             1048576 kB
>   vmemoryuse           infinity kB
> 
> How do I do the same in Linux (without root permissions)?

One way would be:

(ulimit -m 2097152; ./mytest)

This assumes you're using bash as your shell.

You might want to review the resource limits and how they work --
see setrlimit(2) for the kernel's documentation.  See "help ulimit"
for bash's brief-form documentation.  The longer documentation is in
the bash(1) man page.

You never need root privileges to *reduce* one of your resource limits
to a lower value.  Nor do you need root privs to raise your soft limit
up to the hard limit.  However, you do need root privs to raise your
hard limit.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Limit memory consumption of an ad hoc process Victor Sudakov <vas@sibptus.ru> - 2021-07-05 05:40 +0200
  Re: Limit memory consumption of an ad hoc process Greg Wooledge <greg@wooledge.org> - 2021-07-05 14:00 +0200
    Re: Limit memory consumption of an ad hoc process Victor Sudakov <vas@sibptus.ru> - 2021-07-05 18:00 +0200
      Re: Limit memory consumption of an ad hoc process Victor Sudakov <vas@sibptus.ru> - 2021-07-05 18:10 +0200
        Re: Limit memory consumption of an ad hoc process Greg Wooledge <greg@wooledge.org> - 2021-07-05 19:00 +0200
          Re: Limit memory consumption of an ad hoc process Victor Sudakov <vas@sibptus.ru> - 2021-07-06 04:50 +0200
            Re: Limit memory consumption of an ad hoc process The Wanderer <wanderer@fastmail.fm> - 2021-07-06 05:10 +0200
              Re: Limit memory consumption of an ad hoc process Greg Wooledge <greg@wooledge.org> - 2021-07-06 05:20 +0200
              Re: Limit memory consumption of an ad hoc process Greg Wooledge <greg@wooledge.org> - 2021-07-06 05:20 +0200
                Re: Limit memory consumption of an ad hoc process Victor Sudakov <vas@sibptus.ru> - 2021-07-06 06:30 +0200
              Re: Limit memory consumption of an ad hoc process Victor Sudakov <vas@sibptus.ru> - 2021-07-06 06:40 +0200
  Re: Limit memory consumption of an ad hoc process Victor Sudakov <vas@sibptus.ru> - 2021-07-06 06:30 +0200

csiph-web