flet icon indicating copy to clipboard operation
flet copied to clipboard

Possible memory leak in flet.exe when updating page after LineChartDataPoint.y is changed

Open Regmoria opened this issue 1 year ago • 2 comments

Duplicate Check

  • [X] I have searched the opened issues and there are no duplicates

Describe the bug

Memory usage keeps increasing with each 'page.update() after a LineChartDataPoint.y is changed'

Code sample

Code
import flet as ft
import threading
import random
import time

def start(page: ft.Page):
    history = []
    for i in range(100):
        history.append(ft.LineChartDataPoint(i, 0))
    line_chart = ft.LineChart(data_series=[ft.LineChartData(data_points=history)])
    page.add(line_chart)
    
    def change_random():
        while page.loop.is_running():
            x = int(random.random() * 99)
            y = int(random.random() * 99)
            history[x].y = y
            page.update()
            time.sleep(0.01)

    t = threading.Thread(target=change_random)
    t.start()


ft.app(target=start)

To reproduce

Just run the code and watch memory usage of flet.exe

Expected behavior

No response

Screenshots / Videos

Captures

https://github.com/user-attachments/assets/0be61389-7c84-4961-b644-c651221ee5cd

Operating System

Windows

Operating system details

Windows 11

Flet version

0.24.1

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Regmoria avatar Nov 17 '24 09:11 Regmoria