Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory usage continues to increase. #1223

Closed
wangzm5573 opened this issue Mar 27, 2023 · 7 comments
Closed

Memory usage continues to increase. #1223

wangzm5573 opened this issue Mar 27, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@wangzm5573
Copy link

wangzm5573 commented Mar 27, 2023

Memory usage continues to increase although the old controls have been removed.

Code example to reproduce the issue:

import flet, time



def main1(page: flet.Page) -> None:
    column1 = flet.Column(
        alignment = flet.MainAxisAlignment.CENTER,
    )
    column2 = flet.Column(
        alignment = flet.MainAxisAlignment.CENTER,
    )
    container = flet.Container(
        alignment = flet.alignment.center,
        expand = True,
        content = column1
    )
    page.add(container)
    for index in range(1, 10):
        print(index)
        column1.controls.clear()
        hugeThing = flet.Text(
            data = f"{index %10}" *(1024 *1024 *128),
            value = f"{index}"
        )
        column1.controls.append(hugeThing)
        page.update()
        time.sleep(0.1)
        column1.controls.clear()
        page.update()


def main2(page: flet.Page) -> None:
    column1 = flet.Column(
        alignment = flet.MainAxisAlignment.CENTER,
    )
    column2 = flet.Column(
        alignment = flet.MainAxisAlignment.CENTER,
    )
    container = flet.Container(
        alignment = flet.alignment.center,
        expand = True,
        content = column1
    )
    page.add(container)
    for index in range(1, 10):
        print(index)
        container.content = column1
        column1.controls.clear()
        hugeThing = flet.Text(
            data = f"{index %10}" *(1024 *1024 *128),
            value = f"{index}"
        )
        column1.controls.append(hugeThing)
        page.update()
        time.sleep(0.1)
        column1.controls.clear()
        page.update()
        container.content = column2
        page.update()



def main3(page: flet.Page) -> None:
    column1 = flet.Column(
        alignment = flet.MainAxisAlignment.CENTER,
    )
    column2 = flet.Column(
        alignment = flet.MainAxisAlignment.CENTER,
    )
    container = flet.Container(
        alignment = flet.alignment.center,
        expand = True,
        content = column1
    )
    page.add(container)
    for index in range(1, 10000):
        print(index)
        container.content = column1
        column1.controls.clear()
        hugeThing = flet.Text(
            data = f"{index %10}" *(1024 *1024 *128),
            value = f"{index}"
        )
        column1.controls.append(hugeThing)
        page.update()
        time.sleep(0.1)
        column1.controls.clear()
        container.content = column2
        page.update()



flet.app(target = main1, port = 5773, view = flet.FLET_APP, web_renderer = "auto") # normal: Memory usage is 25 ~ 150MB.
flet.app(target = main2, port = 5773, view = flet.FLET_APP, web_renderer = "auto") # normal: Memory usage is 25 ~ 150MB.
flet.app(target = main3, port = 5773, view = flet.FLET_APP, web_renderer = "auto") # bug: Memory usage continues to increase.

Flet version (pip show flet):

Name: flet
Version: 0.5.0.dev1252
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page:
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: C:\Program Files\Python311\Lib\site-packages
Requires: flet-core, httpx, oauthlib, packaging, watchdog, websocket-client, websockets
Required-by:

Operating system: Windows 11

@gbrandt
Copy link

gbrandt commented Mar 27, 2023

Should this be added to #969?

@FeodorFitsner
Copy link
Contributor

@wangzm5773 could you please clarify what process "eats" the memory: Python, flet or fletd?

@wangzm5573
Copy link
Author

Should this be added to #969?

Hmm.. maybe..?

@wangzm5573
Copy link
Author

@wangzm5773 could you please clarify what process "eats" the memory: Python, flet or fletd?

fletBug
It's python.exe

@FeodorFitsner
Copy link
Contributor

Geez, is it 1.4 GB?

@wangzm5573
Copy link
Author

Geez, is it 1.4 GB?

Yes. When running the main3 function, the memory usage will continue to increase rapidly until a MemoryError is raised.

@FeodorFitsner FeodorFitsner added the bug Something isn't working label Apr 5, 2023
@FeodorFitsner
Copy link
Contributor

I've been able to fix this issue. The fix is coming in 0.5.0 release due to today/tomorrow. Good case, thanks :)

FeodorFitsner added a commit that referenced this issue Apr 6, 2023
zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
* Line chart initial commit

* More chart classes

* LineChart Python model

* Use custom flutter_svg library

* aspect_ratio added to all controls

* AspectRatio on Flutter side

* Changed flutter_svg reference to flet-fixes branch

* Charts moved to flet-core package

* Remove --allow-releaseinfo-change flag

* LineChart Python classes

* LineChart stub control added

* LineChart prototype

* LineChart complete

* LineChart datapoint tooltips

* LineChart.on_chart_event

* Fix tests

* shadow and dash_pattern

* spot indicators for line chart

* Dot marker style

* Line chart point

* Point gradients

* Show below/above lines

* selected below line

* selected points on non-interactive charts

* Linechart adjusted for "monthly sales" example

* pip install --upgrade pip

* cutoff Y

* point_line_start/end

* Renamings for BarChart

* BarChart data model python and dart

* BarChart first steps

* BarChart tooltip and touch event

* PieChart

* remove show_title from piechart

* remove interactive and border from piechart

* Added shadow to TextStyle

* Automatic sizing of line and bar charts

* Bump Flet version to 0.5.0, update changelog

* Bump Pyodide 0.23

Closes flet-dev#1241

* Updated changelog with Pyodide 0.23

* Fixed memory leak when deleting orphaned controls

Fix flet-dev#1223

* Remove all page references

* Reliably remove closed sessions from memory

* Changelog updated with memory leak fixes

Fix flet-dev#1223, Fix flet-dev#969

* Cleaup imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants