Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 May 2008 10:27:33 -0700
From:      "Brad Penoff" <penoff@cs.ubc.ca>
To:        "Bill Moran" <wmoran@potentialtech.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: resident memory limit
Message-ID:  <b89c3c270805211027o12fa20c8jb3fd6a635e764888@mail.gmail.com>
In-Reply-To: <20080521090919.e3e777ec.wmoran@potentialtech.com>
References:  <b89c3c270805201320i36955dccv9c643543e1b3c291@mail.gmail.com> <20080520165437.36413c46.wmoran@potentialtech.com> <b89c3c270805201439nf8adbd4s954a80bb82c72ba@mail.gmail.com> <b89c3c270805210143l2019442am233aeeb8748fc776@mail.gmail.com> <20080521090919.e3e777ec.wmoran@potentialtech.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, May 21, 2008 at 6:09 AM, Bill Moran <wmoran@potentialtech.com> wrote:
> In response to "Brad Penoff" <penoff@cs.ubc.ca>:
>
>> On Tue, May 20, 2008 at 2:39 PM, Brad Penoff <penoff@cs.ubc.ca> wrote:
>> > On Tue, May 20, 2008 at 1:54 PM, Bill Moran <wmoran@potentialtech.com> wrote:
>> >> In response to "Brad Penoff" <penoff@cs.ubc.ca>:
>> >>>
>> >>> I have an application that runs on Linux or Mac OS X but seems to have
>> >>> a problem when I run on FreeBSD (6.3 or 7).  The issue is the memory
>> >>> footprint for the application (osubw_sctpclien below) is quite large;
>> >>> on Linux it can be as much as 950 MB in resident memory, according to
>> >>> top.  However, on FreeBSD I start to get ENOMEM always around the time
>> >>> my resident memory size is about 200 MB.
>> >>>
>> >>> I read a few posts and have seen people fixing their problems by
>> >>> adjusting kern.maxdsiz in /boot/loader.conf and/or by adding a swap
>> >>> file.  I've tried both and for my application, it still seems to be
>> >>> limited to 200 MB resident memory regardless of maxdsize and swap file
>> >>> setting.  I wrote a toy application (malloctest below) that calls
>> >>> malloc in a while(1) and breaks once it gets ENOMEM (doing another
>> >>> while(1) so it doesn't exit); this application's memory size in top
>> >>> always matches the kern.maxdsiz setting, however it has a very low
>> >>> resident memory number, according to top.
>> >>
>> >> Have a look at /etc/login.conf and the associated man pages.
>> >>
>>
>> BTW, we've seen the exact behavior on FreeBSD 7 as well (6.3 was
>> reported here).  We've tried on different hardware as well, and keep
>> getting haunted by this resident memory limit that we don't know how
>> to set.
>>
>> Any idea why, in the data I originally reported, I can allocate
>> kern.maxdsiz + swap (see SIZE from top output) for malloc(1 MB) in a
>> while loop, yet the top value for RES is always really low?
>>
>> How come, in contrast, my application starts to report ENOMEM when
>> SIZE is 203 MB and RES is 201 MB?  This is why I titled the thread
>> asking about an unknown (to me ;-) limit for resident memory...
>
> It's called memory overcommit.  If the OS thinks it _might_ be able
> to get you the memory, it will allow it.  You only actually use the
> memory when you start putting data in it (hence the difference between
> SIZE and RES)  Add a statement to fill up the malloc()ed memory with
> some sort of data in your loop, and you'll see different behaviour.
>
> As to what's limiting your application, I'm not sure.  What does the
> output of 'ulimit -a' say?
>

Thanks again for your time.


With the default loader.conf, my "limit -a" output is:

Resource limits (current):
  cputime          infinity secs
  filesize         infinity kB
  datasize           524288 kB
  stacksize           65536 kB
  coredumpsize     infinity kB
  memoryuse        infinity kB
  memorylocked     infinity kB
  maxprocesses         5547
  openfiles           11095
  sbsize           infinity bytes
  vmemoryuse       infinity kB

My application starts getting ENOMEM when I have 201 MB of resident memory.



When I change my loader.conf to match the 2 GB of physical memory that I have:
kern.maxdsiz="2147483648"
kern.maxssiz="2147483648"
kern.dfldsiz="2147483648"

...and reboot, then my "limit -a" output is:

Resource limits (current):
  cputime          infinity secs
  filesize         infinity kB
  datasize          2097152 kB
  stacksize         2097152 kB
  coredumpsize     infinity kB
  memoryuse        infinity kB
  memorylocked     infinity kB
  maxprocesses         5547
  openfiles           11095
  sbsize           infinity bytes
  vmemoryuse       infinity kB


However, the application still seems to max out at 201 MB of resident memory.


People suggest to fix my login.conf but the memory related fields are
set to unlimited... Any ideas where this 201 MB limit of resident
memory comes from?


Thanks!
brad



>>
>> Any other suggestions?
>>
>> brad
>>
>> >
>> > Thanks for the prompt reply.
>> >
>> > This system has the default settings for all users set to "unlimited"
>> > for more or less all login.conf categories.  I've pasted them below.
>> > My application uses a raw socket so I was running it as root, which
>> > also uses the default settings.
>> >
>> > It mentioned that setting memoryuse is the same as setting both -cur
>> > and -max ; any ideas why memoryuse is saying it's unlimited even
>> > though it is not?  I tried explicitly setting -cur to 1000M and it
>> > still started giving ENOMEM around 200 MB resident memory in top...
>> >
>> > brad
>> >
>> >
>> > default:\
>> >        :passwd_format=md5:\
>> >        :copyright=/etc/COPYRIGHT:\
>> >        :welcome=/etc/motd:\
>> >        :setenv=MAIL=/var/mail/$,BLOCKSIZE=K,FTP_PASSIVE_MODE=YES:\
>> >        :path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin
>> > /usr/local/bin /usr/X11R6/bin ~/bin:\
>> >        :nologin=/var/run/nologin:\
>> >        :cputime=unlimited:\
>> >        :datasize=unlimited:\
>> >        :stacksize=unlimited:\
>> >        :memorylocked=unlimited:\
>> >        :memoryuse=unlimited:\
>> >        :filesize=unlimited:\
>> >        :coredumpsize=unlimited:\
>> >        :openfiles=unlimited:\
>> >        :maxproc=unlimited:\
>> >        :sbsize=unlimited:\
>> >        :vmemoryuse=unlimited:\
>> >        :priority=0:\
>> >        :ignoretime@:\
>> >        :umask=022:
>> >
>> > root:\
>> >        :ignorenologin:\
>> >        :tc=default:
>> >
>> >
>> >
>> >> --
>> >> Bill Moran
>> >> http://www.potentialtech.com
>> >>
>> >>
>> >
>> _______________________________________________
>> freebsd-questions@freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
>
>
> --
> Bill Moran
> http://www.potentialtech.com
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?b89c3c270805211027o12fa20c8jb3fd6a635e764888>