Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Mar 2009 11:52:06 +0100
From:      cpghost <cpghost@cordula.ws>
To:        Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Speeding up exit(2)?
Message-ID:  <20090315105206.GB1282@phenom.cordula.ws>
In-Reply-To: <alpine.BSF.2.00.0903151106210.41179@wojtek.tensor.gdynia.pl>
References:  <20090315091301.GB1051@phenom.cordula.ws> <alpine.BSF.2.00.0903151027050.41063@wojtek.tensor.gdynia.pl> <20090315100141.GA1282@phenom.cordula.ws> <alpine.BSF.2.00.0903151106210.41179@wojtek.tensor.gdynia.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Mar 15, 2009 at 11:09:00AM +0100, Wojciech Puchar wrote:
> >>
> >> is it your program and you are sure it's on exit?
> >
> > Every memory hungry program is concerned; and yes: it happens exactly
> > on exit.
> 
> strange.
> i just wrote a test program
> 
> #include <stdio.h>
> int test[1024*1024*128];
> main() {
>   int a;
>   for(a=0;a<1024*1024*128;a++) test[a]=a;
>   puts("end");
> }
> 
> it fills 512MB RAM and then ends. i have 256MB RAM in laptop
> 
> it swapped a lot, then wrote "end" and immediately exited.

Hmmm... yes, it's strange. With malloc-ed space, exit is also very
fast. On a 2 GB machine with amd64, exit is almost immediate:

----- snip ----------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>

#define NRGIGS 4
#define BIGSIZE (1024*1024*1024)
#define SOMETIME 15

main() {
  int a;
  char *p;

  for (a=0; a<NRGIGS; a++) {
    p = (char *)malloc(BIGSIZE);
    bzero(p, BIGSIZE);
  }

  printf("about to end in %d seconds...\n", SOMETIME);
  sleep(SOMETIME);
  printf("end now.\n");
  return 0;
}
----- snip ---------------------------------------------

If I find a way to isolate the problem, I'll post it here.

Thanks,
-cpghost.

-- 
Cordula's Web. http://www.cordula.ws/



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