Re:Go memory ballast: How I learnt to stop worrying and love...
by jerf on Monday December 02, 2019 @09:31AM
(#21682587)
"So the solution the article suggesting is to "Use a big buffer (and later slice it for each client(????)) instead of create buffer for each client"?"
No, it's actually just "create a big buffer and don't drop the reference". It's never used for anything except changing some numbers the GC uses to do its logic. Since it doesn't actually end up in physical RAM, it's doesn't consume significant resources either. It's just a funny-looking way at the Go-languange-level to twiddle some numbers to make the GC act differently.
Allocating a big slice and handing out chunks of it does have its uses, basically, arena allocation flavored by being used in a GC'd language. But that's not what this is.
Re:Go memory ballast: How I learnt to stop worrying and love...
by nirui on Monday December 02, 2019 @09:01PM
(#21689263)
Oh I got it finally. I was wondering why the article does not mention how to actually _use (read/write)_ that buffer after it's been allocated other than just keeping it alive (and do nothing else).
Thank you for sum thing up.
If above is true, then I have one question: What if some where down the line, somebody calls append on that buffer?
Could be a downside.https://play.golang.org/p/JiVKypGHQdR