memory leak in Python 3.13 free-threaded build
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 18.8k
- Forks
- 2.8k
- Merge medio
- 16 h 26 min
- PR fusionados (30 d)
- 21
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza ejecutando el bucle destilado de BaseFigure con Python 3.13.3t y observa su consumo de memoria. Inspecciona plotly/basedatatypes.py alrededor de la línea 581 y, después, compara el comportamiento con esa línea comentada. Se considera terminado cuando se haya identificado la causa y confirmado que la creación repetida de BaseFigure ya no provoca un crecimiento constante de la memoria.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- performance
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100