Alex Stewart ([info]imlex) wrote,
  • Mood: happy

exit(3)ing is faster

Say you're at the end of your program. All the work is done and you want to quit. But say that you’ve got some big objects laying around. If all you have to do in your destructors is de-allocate memory, I’ve re-discovered that you can avoid having your objects destroyed by calling exit(3) rather than returning from main. This really helped in my situation, below.

1006: alex@minusone:~/fully-factoring$ time ./full 30000000
There are 1857859 primes.
The largest is 29999999.

real    1m16.196s
user    0m40.990s
sys     0m1.832s
1009: alex@minusone:~/fully-factoring$ time ./full 30000000
There are 1857859 primes.
The largest is 29999999.

real    0m35.794s
user    0m32.942s
sys     0m1.621s

The first is with a return 0; the second calls exit(0).


  • Post a new comment

    Error

    Your IP address will be recorded 

  • 3 comments

Deleted comment

[info]quikchange

July 28 2005, 00:45:24 UTC 6 years ago

Precisely. By omitting unnecessary cleanup, it can finish faster.

[info]canoe_drew

July 28 2005, 14:43:30 UTC 6 years ago

duh!

Just don't try it in win98!

[info]kinthelt

July 29 2005, 14:34:26 UTC 6 years ago

Re: duh!

No kidding!
Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…