devops

Using Python for DevOps tasks like automation, scripting, and infrastructure work.

Python Memory Management: References, Garbage Collection, and the GIL

Python memory management is the quiet engine running under every program you write. You never call malloc() and you never call free(), yet objects appear when you need them and vanish when you do not. This post opens the hood: reference counting, generational garbage collection, circular references, the Global Interpreter Lock (GIL), weak references, and how to measure real memory use with tracemalloc and sys.getsizeof(). “Simplicity does not precede complexity, but follows it.” Alan Perlis, Epigrams on Programming Last Updated: ... Read More