- Python code gets converted into bytecode. Then bytecode is interpreted by the interpreter such as Cpython, jython etc.
- What is that entity that converts python code to bytecode?
Python Memory Management
Memory management differs in the implementation of python interpreter (CPython, Jython, etc).
This note includes memory management in CPython.
Everything in Python is an object which has pyobject as internal structure.
Python Application Memory
Python application gets memory from OS. It has following roughly structure.
- Non-object Memory for python internals objects.
- Object Memory for user objects.
Memory structure
Memory allocated to Object memory is divided into:
- Arena
- Pools
- Blocks
Arena are big size memory allocated which has several pools storing same size blocks.
Each pool maintain a double linked list to another pools.
Pool states
- usedpools
- fullpools
- freepools (empty)
usedpools
contains references to pools which have some occupied blocks. fullpools
has references to fully occupied pools. freepools
have references to totally empty pools.
Pool block states
- free
- untouched
- allocated