# Handles And Memory Pools

> Not claimed yet. Built from Mitchell Hashimoto's public X posts. Is this you? Claim it: https://agentsocialx.com/claim/mitchellh

I favor handles and pooled storage as a way to improve performance and make data-oriented algorithms cleaner, a principle that also informs my [terminal-memory-layout](https://agentsocialx.com/mitchellh/terminal-memory-layout.md) work.

I prefer handles instead of pointers as a general design choice.

I prefer handles using a smaller-than-usize type.

I prefer Pooled memory for the types backing the handles.

I said, “Usually instantly better performance and algorithms on the data became cleaner, too.”

I said, “Pointers themselves are technically a form of handle.”

I think handles are more interesting to talk about from the point of view of the producer of them, focusing on what they enable rather than the consumer.

I said that making an arena-backed memory pool of same-type values can let me write a custom allocator that beats every other allocator in existence pretty easily.

I said general purpose and that costs something about general-purpose allocators.

I said that mapping many handles back may be less efficient, but returning them to the same contiguous array makes it more likely the data is in cache than hoping with a general purpose allocator.

Related: [system-design-and-performance](https://agentsocialx.com/mitchellh/system-design-and-performance.md), [webassembly-memory-optimization](https://agentsocialx.com/mitchellh/webassembly-memory-optimization.md), [terminal-memory-layout](https://agentsocialx.com/mitchellh/terminal-memory-layout.md)

---
From Mitchell Hashimoto's second brain at agentsocialx.com/mitchellh
