Scroll to navigation

FORKBOMB(8) System Manager's Manual FORKBOMB(8)

NAME

forkbomb - eat system resources

SYNOPSIS

forkbomb [options]

AUTHOR

This program and manual page was written by Radim Kolar hsn@netmag.cz, for fun (but may be used for serious tasks).

DESCRIPTION

forkbomb is a simple resource hog program.

OPTIONS

The programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options are included below.

-?, -h, --help
Show summary of options.
Show version of program.
Allows running with euid==0.
Run for infinite time.
Eat CPU time. If -M is also used, write to allocated memory instead of running infinite loop.
Fork infinite number of self copies.
Lets go to House of Dead. You can not bring bombs there.
Allocate all available memory.
Write to every page in allocated memory. Implies -m.
Set maximum execution time.
Set memory allocation limit per process.
Allocate memory in groups of num pages.
Don't wait for safety alarm expiration (useful only with -m/-M option for realloc() benchmarking)

EXIT STATUS

0 - your system has survived.
1 - Insufficient RTFM detected.

CLASSICS FORKBOMB

forkbomb -f

crash. Can not switch virtual console, can not ping, death.
do not crash but runs very slowly.
Excellent result, runs with only small slowdown.
allocates too much wired memory and that hangs the system. Hang is not that good as in Linux 2.4, because you can switch virtual consoles.

PLAIN REALLOC RESULTS

forkbomb -m -l 32 -i 256 --quit

I have tested then only with glibc 2.3.2 and results are excellent. Both finished test with instantly with 0.00 CPU time.
The realloc() has several serious problems. First problem is that realloc is really slow, It needs 12 seconds to run this test. It looks like it unnecessary copies data on reallocation. Second problem is if you allocate more than -l 18 MB of memory, malloc eats about 3 times more memory from system than needed. Maybe this have something to do with size of malloc cache size (default 16 pages). FreeBSD people should really look at their libc/stdlib/malloc.c

REALLOC WITH TOUCH

forkbomb -l 32 -i 256 -M --quit

Linux is also super fast there, test run is 0.3 sec. Linux allocates bigger memory blocks directly from mmap and uses mremap for resizing. There is no need for copying data around.
FreeBSD runs for 9.9 seconds which is FASTER that without touching memory at all.

HUNGRY FORKBOMBS

forkbomb -f -c

dead.
ls command takes between 100 to 200 seconds. System load was 840.
ls command takes 70 seconds to execute. System load was 800.

TODO

Incorporate user feedback.

COPYING

Forkbomb program and this manual page are both public domain.

13 May 2005