4 ms·
> Don't use pointers at all, always allocate structs on the stack Unless one makes the rookie mistake of passing these structs to pkg log (which box to any/int
by ignoramous 4mo ago
> Don't use pointers at all, always allocate structs on the stack
Unless one makes the rookie mistake of passing these structs to pkg log (which box to any/interface{}) instead of slog [0]... then they escape to heap. If a project relies on avoiding heap allocs, prudent to 'go build -gcflags="-m"' on every check-in, and review the diff from that too.
[0] https://go.dev/blog/slog https://go.dev/blog/slog
- Fire-Dragon-DoL 4mo agoGood to know, but wouldn't that be something that pops up when profiling?
- ignoramous 4mo agoRuntime profiling / tracing (runtime.MemProfile & debug.FlightRecoder)? Yes... At test time (go bench -benchmem), also yes.