# Interfaces 101 : Heap Escape Ep. 2

DevFeed: [Interfaces 101 : Heap Escape Ep. 2](<https://devfeed.tech/articles/interfaces-101-heap-escape-ep-2-22215.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2023/02/interfaces-101-heap-escape.html>)

Published: 2023-02-08T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Go Language](<https://devfeed.tech/topics/go-language.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Code](<https://devfeed.tech/topics/code.md>), [Logging](<https://devfeed.tech/topics/logging.md>)

Tags: [benchmark](<https://devfeed.tech/tags/benchmark.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [escape-heap](<https://devfeed.tech/tags/escape-heap.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [go](<https://devfeed.tech/tags/go.md>), [golang](<https://devfeed.tech/tags/golang.md>), [inlining](<https://devfeed.tech/tags/inlining.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [log-variables](<https://devfeed.tech/tags/log-variables.md>), [logging](<https://devfeed.tech/tags/logging.md>), [performance](<https://devfeed.tech/tags/performance.md>)

## AI overview

This video examines the performance implications of using interfaces in Go, including how interface use can cause variables to escape to the heap. It demonstrates benchmarking code, examining compiler optimizations, identifying heap allocations, and preventing function inlining.

## Source excerpt

Introduction In episode 1, Miki had two functions that performed the similar operation, but returned different types. To refactor this, Miki rewrote both functions as a generic function that allowed him to specify the type to be returned during invocation. In some cases, the compiler may not recognise a type, thus, Miki gives a few pointers on manually telling a generic function which type to use. After demonstrating how to return different types with a generic function, Miki limited the types his generic function would accept with an interface.