The below article talks about minimizing garbage collection. Are there any best practices from a programmers perspective to make garbage collection efficient in Go?
Asked
Active
Viewed 319 times
1
-
4Yes: Do not produce garbage. How? Measure your allocations and get rid of the most ugly ones. – Volker Nov 23 '16 at 14:34
-
@Volker this is the answer in Go fashion :) – mutantkeyboard Nov 23 '16 at 14:54
-
What exactly is your question, since you're linking to the same question which already has multiple answers? – JimB Nov 23 '16 at 15:03
-
For example, does it help to allocate contiguous blocks of memory, allocate bigger chunks upfront, or reduce the number different variables created in order to make garbage collection go faster? – user2443447 Nov 23 '16 at 15:29
-
2The only thing that really helps is: Measure it. – Volker Nov 23 '16 at 15:39
1 Answers
0
"how to analyse golang memory" gives some criteria, but the best approach remains to measure:
- "Visualising the Go garbage collector"
- "Garbage Collector Trace":
GODEBUG=gctrace=1 ./myserver

VonC
- 1,262,500
- 529
- 4,410
- 5,250