memory leak in Python 3.13 free-threaded build
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 18.8k
- フォーク
- 2.8k
- 平均マージ
- 16時間 26分
- マージ済み PR(30日)
- 21
説明
I spent some time trying to debug a memory leak caused by calling plotly.express.line within a Dash live update callback under a Python 3.13.3t (free-threaded). Setting PYTHON_GIL=0 or PYTHON_GIL=1 appears to make no difference.
By no means have I located the root cause of the issue (not yet anyway), but I've been able to at least narrow it down to at least one problematic line of code in the BaseFigure class
https://github.com/plotly/plotly.py/blob/main/plotly/basedatatypes.py#L581
If I run the example code shown below (which is HIGHLY distilled from the originating Dash app I was trying to debug), the memory footprint seems to steadily climb with each iteration. If I comment out the offending line within BaseFigure (shown above), the memory footprint remains stable
#!/usr/bin/env -S python3 -u
import sys
import time
from plotly.basedatatypes import BaseFigure
gil = sys._is_gil_enabled()
print(f'GIL enabled = {gil}')
while True:
BaseFigure()
BaseFigure()
BaseFigure()
time.sleep(.01)
For long running applications like the one described earlier, slow and steady memory consumption issues are causing some rather significant issues.
System details
OS: docker://python:3.12-slim-bookworm
Arch: aarch64
Python version: uv python install 3.13.3t
Plotly version: 6.0.1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、Python 3.13.3t で簡略化した BaseFigure ループを実行し、そのメモリ使用量を観察します。plotly/basedatatypes.py の 581 行目付近を調べ、その行をコメントアウトした場合の動作と比較します。BaseFigure を繰り返し作成してもメモリが継続的に増加しなくなったことを確認し、原因を特定できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- performance
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100