Higher Memory Footprint

GIL-free Python can lead to increased memory consumption in multi-threaded data science tasks due to per-object locking, additional thread-safety mechanisms, and the adoption of new memory allocators like `mimalloc` which can have more overhead compared to `pymalloc`.

The top 3

  1. Per-Object State: The Memory Cost of True Concurrency: Removing the GIL necessitates thread-safe reference counting, often through biased reference counting, which adds per-object metadata and overhead to each Python object, increasing memory usage.
  2. Typical Memory Overhead: Up to 20% for GIL-Free Python: Early benchmarks and analyses indicate that GIL-free Python builds can incur a memory overhead of approximately 20% due to the new thread-safety mechanisms and memory allocator changes.
  3. Small Objects: The Biggest Memory Impact in GIL-Free Python: Workloads heavily reliant on numerous small Python objects like integers, short strings, or small list/dict elements will likely experience a disproportionately higher memory footprint due to the per-object overhead of new thread-safety mechanisms.

Sources

Open the full topic