# Python's Memory Allocator Rarely Shrinks: A Deep Dive

Original title: First Steps into Memory Management in Python

> Hacker News story 49969851 · language: en · submitted 2026-10-05
> Web version: https://zeli.app/story/49969851
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 10 · by [shellpipe](<https://news.ycombinator.com/user?id=shellpipe>) · 💬 2
[original](<https://tech.daniellbastos.com.br/posts/python-memory-management/>) · [HN discussion](<https://news.ycombinator.com/item?id=49969851>)

## Summary

A personal exploration of CPython 3.12's memory management: pymalloc for small objects (≤512 bytes) and malloc for larger ones, reference counting, and the garbage collector. The key insight: once memory is allocated, freeing it doesn't always reduce the memory the OS sees, because the allocator decides what goes back. You can control how long a reference lives, though.

## Key quote

> Once memory is allocated, freeing it doesn't always reduce the memory the OS sees.

---

## Cite

- Page: https://zeli.app/story/49969851
- Date: 2026-10-05
- Source: tech.daniellbastos.com.br (https://tech.daniellbastos.com.br/posts/python-memory-management/)
- Hacker News: https://news.ycombinator.com/item?id=49969851

## Other languages

- zh: https://zeli.app/zh/story/49969851 · markdown: https://zeli.app/zh/story/49969851.md
- ja: https://zeli.app/ja/story/49969851 · markdown: https://zeli.app/ja/story/49969851.md
- ko: https://zeli.app/ko/story/49969851 · markdown: https://zeli.app/ko/story/49969851.md
- de: https://zeli.app/de/story/49969851 · markdown: https://zeli.app/de/story/49969851.md
- es: https://zeli.app/es/story/49969851 · markdown: https://zeli.app/es/story/49969851.md
