On Saturday, May 5, 2018 at 9:30:25 AM UTC-4, s...@whites.team wrote: > > Hi James, > > Thanks for the tip - could you elaborate on your idea of a 'busy loop'? Is > this a loop that is blocked, or just one that is currently operating on > something? I'm not sure what causes GC to act on certain go routines. >
Line 46 in your playground link is a busy loop, and line 57 is a busy loop when you don't need to change the number of goroutines. Nothing blocks the loops in those cases, so they spin using 100% cpu, eventually blocking the GC. > I completely understand that getting the length of the channel isn't > accurate, but that part of the program doesn't need to be particularly > accurate or responsive, so it works okay in the instance. > Except it doesn't work OK here, because you're relying on polling the length with a busy loop, which isn't something you hardly ever want to do. You'll want to refactor this to use synchronization primitives rather than polling. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.