Closed ysicg closed 2 years ago
it appears that this is only happens when an item is created and deleted before DPG starts that the alias is not cleaned up
import dearpygui.dearpygui as dpg
dpg.create_context()
def check_state():
dpg.delete_item('an_new_alias')
print(f"More Text Item (After deleted): {dpg.does_item_exist('an_new_alias')}")
print(f"More Text Alias (After deleted): {dpg.does_alias_exist('an_new_alias')}")
with dpg.window()as mainWin:
dpg.add_text("Some Text", tag="an_alias")
dpg.add_text("More Text", tag="an_new_alias")
print(f"Some Text Item: {dpg.does_item_exist('an_alias')}")
print(f"Some Text Alias: {dpg.does_alias_exist('an_alias')}")
dpg.delete_item('an_alias')
print(f"Some Text Item (After deleted): {dpg.does_item_exist('an_alias')}")
print(f"Some Text Alias (After deleted): {dpg.does_alias_exist('an_alias')}")
dpg.add_button(label="check state", callback=check_state)
dpg.create_viewport()
dpg.show_viewport()
dpg.setup_dearpygui()
dpg.start_dearpygui()
dpg.destroy_context()
If we delete the whole window instead in check_state()
,
dpg.delete_item(mainWin)
Both aliases remain uncleaned.
It appears the aliases are only removed if the app has actually started up. We will need to cover this case.
@ysicg The workaround is to manually remove the alias: dpg.remove_alias("an_alias")
after deleting the item.
commenting out this check will fist this example: https://github.com/hoffstadt/DearPyGui/issues/1350#issuecomment-946833446
probably dig deeper into why this check was implemented and when, could have been before the context was created explicitly in which case it may not be needed anymore, maybe try and find pr and issue that was related to this fix
goes back to commit eb80b71a and then is replaced with https://github.com/hoffstadt/DearPyGui/blob/eb80b71a0ea4ac1c779459c597228e84210739ec/DearPyGui/src/core/AppItems/mvAppItem.cpp#L1078-L1083 from
// in case item registry is destroyed
if (mvApp::IsAppStarted())
{
CleanUpItem(*mvApp::GetApp()->itemRegistry, _uuid);
RemoveAlias(*mvApp::GetApp()->itemRegistry, _alias, true);
}
and
mvApp::IsAppStarted()
was originally implemented in 2c6f1b68
Hello, you can use the following code to reproduce the issue:
#!/usr/bin/env python
#pylint: disable=import-error
#pylint: disable=invalid-name
"""
Simple usage of table with dynamic rows
"""
import dearpygui.dearpygui as dpg
if __name__ == "__main__":
tag="mytableid"
dpg.create_context()
with dpg.window(label="main_window"):
with dpg.table(header_row=True, resizable=True, tag=tag, parent="main_window"):
dpg.add_table_column(label="Name", parent=tag)
dpg.add_table_column(label="Size (bytes)", default_sort=True, parent=tag)
for row in range(0, 100):
with dpg.table_row(parent=tag):
dpg.add_text("col1")
dpg.add_text("col2")
#dpg.delete_item(tag, children_only=False)
#dpg.remove_alias(tag)
with dpg.table(header_row=True, resizable=True, tag=tag):
dpg.add_table_column(label="Name", parent=tag)
dpg.add_table_column(label="Size (bytes)", default_sort=True, parent=tag)
for row in range(0, 4):
with dpg.table_row(parent=tag):
dpg.add_text("col1")
dpg.add_text("col2")
dpg.create_viewport(title='RPM Quick query tool', width=500)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
If you uncomment the following lines
dpg.delete_item(tag, children_only=False)
dpg.remove_alias(tag)
Then the table works fine.
Fixed in next release.
Still problem exist. But this issue also could be solved by doing this:
table_window = None
def get_ClientsTable():
global table_window
if table_window is not None:
dpg.delete_item(table_window)
table_window = None
with dpg.window(label="Clients List", width=gVars.window_width/1.5, height=gVars.window_height, no_collapse=True) as table_window:
with dpg.menu_bar():
dpg.add_menu_item(label="Add row")
with dpg.table(header_row=True, tag="cTable"):
dpg.add_table_column(label="Date", id="date")
dpg.add_table_column(label="Number", id="pc")
dpg.add_table_column(label="Price", id="price")
dpg.add_table_column(label="Admin", id="admin")
It seems to exist some type of memory leak when the deleted item is a node editor. When repeatedly deleting and adding a node editor item the active allocations keep growing. Is this normal? Can anyone confirm this? Thanks.
I have the same problem. I have a node editor and I call up also dpg.show_item_registry() to see what is goign on. When I create and delete a Node (and remove its alias) the registry keeps showing the Node so as I keep doing this the registry keeps growing. The Node though does disapear from the editor. If I use the registry window's Delete button then the item gets deleted.
Version of Dear PyGui
Version: 1.0.2 Operating System: Ubuntu 20.04
To Reproduce
Create an item with an alias and delete it:
Expected behavior
does_alias_exist(alias)
to return False, as it did in v0.8.64.