Gophercamp2026
Back to all speakers
Pranoy Kundu profile picture

Pranoy Kundu

Backend Engineer, OpenProvider

About

I am a seasoned Go developer with extensive experience in building scalable applications. Passionate about writing clean, efficient code, I have contributed to open-source projects and regularly shares knowledge through technical talks and blogs. I also have hands-on expertise in APIs, Automation, Databases, and DevOps tooling

Session at Gophercamp 2026

Understanding Escape Analysis in Go - How Variables Move Between Stack and Heap

As a seasoned Go developer responsible for developing and maintaining a registrar backend to handle connections with about 40 registries and about 1k req/min I have to make sure the system is always well handled and performant. In order to make sure of it, escape analysis is a key part in it that I had to consider in it. - Why Escape Analysis Matters The Go compiler automatically decides where variables lives on the stack (fast, automatically freed) or heap (managed by GC, slower). While many developers never think about memory allocation, understanding escape analysis can be crucial for performance-sensitive code paths. Excess heap allocations increase garbage collection pressure and can slow down applications. - What Escape Analysis Is Escape analysis is a static compiler optimization that analyzes whether a variable can safely be kept on the stack. If a variable’s address escapes the function scope for example because it is returned or stored for later use the compiler must allocate it on the heap. - Code Walkthrough with Examples We’ll explore key patterns that force heap escapes or keep data on the stack: 1. Simple value return vs pointer return 2. Passing pointers and how this affects escape decisions 3. Why local pointers sometimes don’t escape Each example will include the -gcflags="-m" output to show the compiler’s reasoning. - How to Inspect Escape Behavior in Your Code Attendees will learn how to use `go build -gcflags="-m"` to see escape analysis annotations. We’ll interpret compiler messages and explain how they map to code behavior. - Practical Tips to Reduce Unnecessary Heap Allocations Beyond theory, the talk will cover actionable advice: 1. Prefer returning values instead of pointers when possible 2. Be mindful of interfaces and closures that may cause escapes 3. Understand allocations in hot paths and optimize where it matters