*BSD News Article 62846


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.OZ.AU!spool.mu.edu!howland.reston.ans.net!newsfeed.internetmci.com!news.mathworks.com!fu-berlin.de!news.dfn.de!news.gwdg.de!news.gwdg.de!not-for-mail
From: kheuer@gwdg.de (Konrad Heuer)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Resource Limits
Date: 7 Mar 1996 10:33:09 +0100
Organization: GWDG, Goettingen
Lines: 58
Message-ID: <4hmagl$mqf@gwdu19.gwdg.de>
NNTP-Posting-Host: gwdu19.gwdg.de
Summary: Pgm gets only half of data seg limit
Keywords: limit, ulimit
X-Newsreader: NN version 6.5.0 #8 (NOV)


With FreeBSD Release 2.1:

After explicitly resetting the soft resource limits in
/etc/profile and /etc/csh.login I observe that my test
program gets only half of the memory defined by the data limit.

The limits I use are (csh formulation):

limit cputime         900 seconds
limit datasize       8192 kbytes
limit stacksize      1024 kbytes
limit coredumpsize      0 kbytes
limit memoryuse      2048 kbytes
limit memorylocked    256 kbytes
limit maxproc          40
limit openfiles        64

My test program is:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define MEGABYTE  1048576
#define MEMBLOCK  1 * MEGABYTE
#define SECONDS   5

int main(int argc, char *argv[])
{
  void *buffer;
  long memsize = MEMBLOCK;

  while (buffer = malloc(memsize)) {
    memset(buffer, 0, memsize);
    printf("%s: %4d MB\n", argv[0], memsize / MEGABYTE);
    sleep(SECONDS);
    free(buffer);
    memsize += MEMBLOCK;
  }
}

The program terminates after allocating 4 MB. E.g., if I double the
data limit to 16 MB, the program gets 8 MB. All this is independent of
the login shell I use (bash, csh, ksh, tcsh, zsh) except the Bourne
shell which doesn't support limits of course.

Has anyone an idea about that? Is it a misunderstanding of mine or
between the kernel and the shells?

In any case, on other system it works well (AIX, DEC UNIX, SOLARIS).

Thanks for any answer.

Konrad Heuer

Gesellschaft fuer wissenschaftliche Datenverarbeitung mbH Goettingen
Am Fassberg, 37077 Goettingen, Germany     (kheuer@gwdg.de)