-
Try to lay out your data structures sequentially in memory, so they can be loaded from RAM efficiently.
-
Always check to see if a weak pointer’s Value() method returns nil before using the value; the garbage collector may have collected the wrapped pointer.
-
If you know exactly how big a slice needs to be, allocate it with a constant so the compiler can store it on the stack.
-
Check the garbage-collector stats if your code is running slower than expected.
-
If other techniques fail, use the
GOMEMLIMITandGOGCvariables to fine-tune your application’s memory usage.
Progress is saved on this device.