DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

Memory increasing and crash if register raw texture and minimize window

Open zlt999 opened this issue 2 years ago • 11 comments

Version of Dear PyGui

Version: 1.8.0 Operating System: Windows 11

My Issue/Question

Occupied memory keep increasing and app finally crash, if register raw texture and minimize the app window (I'm running code from example: https://dearpygui.readthedocs.io/en/latest/documentation/textures.html#raw-textures)

To Reproduce

Steps to reproduce the behavior:

  1. Run the example code (https://dearpygui.readthedocs.io/en/latest/documentation/textures.html#raw-textures)
  2. Minimize the app window
  3. Wait and check occupied memory

Expected behavior

Hope memory not increasing when using raw texture and minimize the window

Screenshots/Video

Standalone, minimal, complete and verifiable example

# Here's code copied from example
import dearpygui.dearpygui as dpg
import array

dpg.create_context()


texture_data = []
for i in range(0, 100 * 100):
    texture_data.append(255 / 255)
    texture_data.append(0)
    texture_data.append(255 / 255)
    texture_data.append(255 / 255)

raw_data = array.array('f', texture_data)

with dpg.texture_registry(show=True):
    dpg.add_raw_texture(width=100, height=100, default_value=raw_data, format=dpg.mvFormat_Float_rgba, tag="texture_tag")


def update_dynamic_texture(sender, app_data, user_data):
    new_color = dpg.get_value(sender)
    new_color[0] = new_color[0] / 255
    new_color[1] = new_color[1] / 255
    new_color[2] = new_color[2] / 255
    new_color[3] = new_color[3] / 255

    for i in range(0, 100 * 100 * 4):
        raw_data[i] = new_color[i % 4]


with dpg.window(label="Tutorial"):
    dpg.add_image("texture_tag")
    dpg.add_color_picker((255, 0, 255, 255), label="Texture",
                         no_side_preview=True, alpha_bar=True, width=200,
                         callback=update_dynamic_texture)


dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

zlt999 avatar Mar 02 '23 08:03 zlt999

The code sample you provided does not show increasing memory usage on my machine. I'm testing with windows 10. I will have to check a windows 11 machine.

hoffstadt avatar Mar 22 '23 04:03 hoffstadt

Ah by the way, I'm using python version 3.10.7

zlt999 avatar Mar 27 '23 03:03 zlt999

Just found memory also increasing when I lock PC

zlt999 avatar Apr 18 '23 02:04 zlt999

I have observed the same issue on windows 11.

OS: Windows 11 Dearpygui version 1.10 Python 3.11

If you minimize the app the memory for the raw texture seems to not get de-allocated each time a frame update is happening. The memory linearly increases proportionally to the size of the raw texture image. It will increase until the app hangs and crashes. Although no error message is printed in the terminal. If you de-minimize the window then it stops increasing in memory usage but it still does not free the memory that was not deallocated while minimized.

If you increase the size of the raw texture, the effect linearly increases. So it does appear to be a direct issue with the raw texture and windows 11. This did not seem to be an issue on Windows 10, although now all my systems were recently upgraded to 11 so I don't have access to Windows 10 anymore to test. But I only started to get bug reports from users of our apps when they upgraded to 11.

west-rynes avatar Sep 19 '23 11:09 west-rynes

I was able to log into a Windows 10 machine and verified that the issue is isolated to Windows 11.

OS Windows 10 Dearpygui version 1.10 Python 3.11

No issue - only seen on Windows 11.

west-rynes avatar Sep 19 '23 14:09 west-rynes

I have Windows 11 running with the sample code minimized and I'm not seeing any leaks:

image

I'm running Python 3.9, 3.10, and 3.11. I'm using an AMD GPU. What GPU are you guys using?

hoffstadt avatar Apr 13 '24 19:04 hoffstadt

I just ran the code and if I minimize the window and then look in the task manager, the python process memory continues to linearly increase until the app uses all available memory and crashes. If I don't minimize the window it does not do this, the memory usage stays constant.

The system I just tested it on is a HP ZBook Firefly G8 which has a NVIDIA T500 (4 GB GDDR5 dedicated) graphics card and Intel Iris Xe Graphics.

I am running python 3.11.

west-rynes avatar Apr 15 '24 13:04 west-rynes

What timeframe? I let it run for about 10 mins.

hoffstadt avatar Apr 15 '24 22:04 hoffstadt

It starts happening immediately. I can see the memory usage start to increase right after minimizing. On Apr 15, 2024, at 4:17 PM, Jonathan Hoffstadt @.***> wrote: What timeframe? I let it run for about 10 mins.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

west-rynes avatar Apr 16 '24 02:04 west-rynes

Here's the environment I'm using

  • OS: Windows 11
  • CPU: 12th Gen Intel(R) Core(TM) i7-1260P 2.10 GHz
  • GPU: NA
  • Python: 3.10.7 & 3.10.8
  • dearpygui: 1.10.0

zlt999 avatar Apr 18 '24 02:04 zlt999