gosieve
gosieve copied to clipboard
Added Memory Clean-up
Added a cascading memory clean-up effect based on panics caused by writing to closed channels.
Usage:
primes := Sieve()
close(primes)
This allows you to create multiple fast prime-number generators without suffering from massive memory problems.
Thanks for writing this in the first place.
sorry for late response, for some reason I didn't see this coming thru my email.
I wrote this as a toy example to play with goroutines and didn't quite envision this to be used in production, mainly due to the fact that it spawns a lot of goroutines. I'm sure there are better ways to generate prime faster with lower memory usage!