I have a Go program that runs continuously and completely relies on goroutines + 1 manager thread. The main thread just calls goroutines and otherwise sleeps.
A memory leak has occurred. The program uses more and more memory until it depletes all 16 GB of RAM + 32 GB of SWAP, and then every panic in the hill. Actually, the OS memory causes a panic, usually the fork/exec ./anotherapp: cannot allocate memory when I try to execute anotherapp .
When this happens, all worker threads will panic and recover and restart. Thus, each goroutine will panic, recover, and restart ... at this point, memory usage will not decrease, it remains at 48 GB, although at the moment, almost nothing is allocated. This means that all goroutines will always panic, as there is never enough memory until the entire executable file is killed and completely rebooted.
All this is about 50,000 lines, but the current problem area is as follows:
type queue struct { identifier string type bool } func main() {
As far as I can see, when the do function (last line) ends, either ending or panicking, the runit function runit , which completely completes the goroutine, which means all memory from this goroutine should now be free. This is what happens. It happens that this application uses more and more memory until it can function, all panic runit goroutines, and yet the memory is not reduced.
Profiling does not show anything suspicious. The leak seems to be outside the profiling area.