Brussels / 2 & 3 February 2019


Memory Management in Python

A Short Overview of CPythons Memory Management

Learn what is going on behind the scene about memory. How CPython allocates memory? How it manages Private Heap? Does it uses abstractions for managing the memory? Does python relase memory back to the system? Learn how python GC works, reference counting and generational GC. How generations classified? How does reference counting mechanism work? This talk is going to try to answer all this questions.

  • Motivation about that subject. Why do i need to know this stuff? What is the effect of these things on my code quality? Is that lecture enough for being a master about this subject?

  • Understanding Objects Everything is an object in python (even code). If we want to understand what is going on behind the scene about memory allocation for objects first we should understand objects. This part has a cpython code reference for PyObject. We are going to learn python objects with seeing how they implemented.

  • Memory Management Model Python has a great system about managing the memory (the private heap). Heap managed by +1th layer but the main part of this talk is +2th layer, object allocation. We'll discuss them

  • Small Object Threshold Classifies objects into 2 sections. If size of an object bigger than 512 it is big else it is small.

  • Abstractions We'll talk about abstractions, Arena > Pool > Block

  • Deallocations We'll talk about GC, reference count, counting mechanism, generational gc, mark & sweep, generations.


Photo of Batuhan Taşkaya Batuhan Taşkaya