2 ms·
It's not a matter of allocation since there isn't a way to manually free memory in Go. The GC basically doesn't do anything if there isn't memory pressure. Once
by withinboredom 3y ago
It's not a matter of allocation since there isn't a way to manually free memory in Go. The GC basically doesn't do anything if there isn't memory pressure. Once your applications starts feeling some memory pressure, the GC will start spending CPU to free up memory. This is a non-disputable fact of how Go works, in general.
- logicchains 3y ago>It's not a matter of allocation It's absolutely a matter of allocation, since the more you allocate, the more work the GC will have to do. If you write clean, memory-friendly code (e.g. reusing buffers, favouring stack allocation), then you'll generate a lot less garbage and the GC will spend less time collecting it.
- 4ad 3y ago> It's not a matter of allocation > Once your applications starts feeling some memory pressure I rest my case.
- Yasuraka 3y ago>The GC basically doesn't do anything if there isn't memory pressure It will run every 2 minutes, if it hasn't run otherwise https://github.com/golang/go/blob/9b4b3e5acca2dabe107fa2c3ed963097d78a4562/src/runtime/proc.go#L5930 https://github.com/golang/go/blob/9b4b3e5acca2dabe107fa2c3ed...
- d-z-m 3y agoI think bradfitz knows how Go works.