notexOPENOverview
Notex/Languages/Code Review: Working with the Garbage Collector
04.18LESSON 18 OF 20 · 1 MIN READ

Code Review: Working with the Garbage Collector

Always free to read
  • 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 GOMEMLIMIT and GOGC variables to fine-tune your application’s memory usage.

Progress is saved on this device.
KEEP EXPLORING

One note leads to another.

Back to the library →
⌕
Search across the entire library ⌘ K