Speeding up exit(2)?
cpghost
cpghost at cordula.ws
Sun Mar 15 03:52:09 PDT 2009
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/
More information about the freebsd-questions
mailing list