I am trying to learn go so I thought I would write a password cracker to
test out go's concurrency. My design for this was to have a loop that
creates all the possible combination of password and for each one fire off
a new goroutine that hashes the password and compared it against the hash I
already had. A simple example for the characters A - Z and 2 bytes long
would be http://play.golang.org/p/lYVKF8GG3l
This works perfectly well for up to 4 characters but when I get into 5
characters that includes A-Z, a-z,0-9 and special characters this is trying
to create over a billion goroutines which ends up using all the ram on the
machine and the program terminates with "signal 9" and I get the below in
Sep 28 18:03:29 localhost kernel: Out of memory: Kill process 2050 (a.out)
score 947 or sacrifice child
Sep 28 18:03:29 localhost kernel: Killed process 2050, UID 501, (a.out)
total-vm:4725900kB, anon-rss:3685824kB, file-rss:20kB
I would like to just let the Waitgroup work out how many threads it can
handle at once without getting killed but I doubt this is possible.
How would I go about limiting this?
What would be a reasonable number to limit it to ?
Would I be able to make this adjustable by amount of Ram or is this a
stupid thing to try to do?