memory leak in Python 3.13 free-threaded build
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 18.8k
- Forks
- 2.8k
- Merge médio
- 16h 26min
- PRs com merge (30d)
- 21
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece executando o loop reduzido de BaseFigure no Python 3.13.3t e observe seu uso de memória. Inspecione plotly/basedatatypes.py próximo à linha 581 e, em seguida, compare o comportamento com essa linha comentada. Está concluído quando a causa tiver sido identificada e for confirmado que a criação repetida de BaseFigure não causa mais um crescimento contínuo da memória.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- performance
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Precisa de esclarecimento
- Facilidade para iniciantes
- 35/100