Skip to content

Using DataFrames causes memory leaks in the browser. #11910

@athene20

Description

@athene20

Describe the bug

Using DataFrames causes memory leaks in the browser. Memory usage continues to increase.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

  1. Start Gradio with the code below. The sample code is set to 10,000 lines for quick verification.
import numpy as np
import gradio as gr

def outList():
    r = np.random.randint(0, 10, (10000, 10)).tolist()
    return r

def outDataFrame():
    r = np.random.randint(0, 10, (10000, 10)).tolist()
    return gr.DataFrame(value=r)

def outUpdate():
    r = np.random.randint(0, 10, (10000, 10)).tolist()
    return gr.update(value=r)

with gr.Blocks() as demo:
    with gr.Row():
        useList = gr.Button("Use np.tolist")
        useDataFrame = gr.Button("Use gr.DataFrame")
        useUpdate = gr.Button("Use gr.update")
    with gr.Row():
        out = gr.Dataframe()
    useList.click(fn=outList, inputs=None, outputs=out)
    useDataFrame.click(fn=outDataFrame, inputs=None, outputs=out)
    useUpdate.click(fn=outUpdate, inputs=None, outputs=out)

demo.launch()
  1. After accessing the browser, press any button to update the data.
  2. Each time you press the button, memory usage continues to increase, eventually causing the tab to become unresponsive.

Screenshot

No response

Logs

System Info

1. System#1
Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 5.45.0
gradio_client version: 1.13.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
anyio: 4.10.0
audioop-lts is not installed.
brotli: 1.1.0
fastapi: 0.116.1
ffmpy: 0.6.1
gradio-client: 1.13.0
groovy: 0.1.2
httpx: 0.28.1
huggingface-hub: 0.34.4
jinja2: 3.1.6
markupsafe: 2.1.5
numpy: 2.2.3
orjson: 3.11.2
packaging: 24.2
pandas: 2.3.2
pillow: 11.3.0
pydantic: 2.11.7
pydub: 0.25.1
python-multipart: 0.0.20
pyyaml: 6.0.2
ruff: 0.12.10
safehttpx: 0.1.6
semantic-version: 2.10.0
starlette: 0.47.2
tomlkit: 0.13.3
typer: 0.16.1
typing-extensions: 4.14.1
urllib3: 2.5.0
uvicorn: 0.35.0
mcp is not installed.
pydantic: 2.11.7
authlib is not installed.
itsdangerous is not installed.


gradio_client dependencies in your environment:

fsspec: 2025.7.0
httpx: 0.28.1
huggingface-hub: 0.34.4
packaging: 24.2
typing-extensions: 4.14.1
websockets: 15.0.1


1. System#2
Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 5.43.1
gradio_client version: 1.12.1

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 24.1.0
anyio: 4.10.0
audioop-lts is not installed.
brotli: 1.1.0
fastapi: 0.116.1
ffmpy: 0.6.1
gradio-client: 1.12.1
groovy: 0.1.2
httpx: 0.28.1
huggingface-hub: 0.34.4
jinja2: 3.1.6
markupsafe: 3.0.2
numpy: 2.2.6
orjson: 3.11.2
packaging: 25.0
pandas: 2.3.2
pillow: 11.3.0
pydantic: 2.11.7
pydub: 0.25.1
python-multipart: 0.0.20
pyyaml: 6.0.2
ruff: 0.12.10
safehttpx: 0.1.6
semantic-version: 2.10.0
starlette: 0.47.3
tomlkit: 0.13.3
typer: 0.16.1
typing-extensions: 4.14.1
urllib3: 2.5.0
uvicorn: 0.35.0
mcp is not installed.
pydantic: 2.11.7
authlib is not installed.
itsdangerous is not installed.


gradio_client dependencies in your environment:

fsspec: 2025.7.0
httpx: 0.28.1
huggingface-hub: 0.34.4
packaging: 25.0
typing-extensions: 4.14.1
websockets: 15.0.1

Severity

Blocking usage of gradio

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions