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
Deleting an item doesn't clean up its alias [v1.0.2] #1350
Comments
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 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: |
DearPyGui/DearPyGui/src/core/AppItems/mvAppItem.cpp Lines 50 to 55 in a68b849
commenting out this check will fist this example: #1350 (comment) 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 eb80b71 and then is replaced with DearPyGui/DearPyGui/src/core/AppItems/mvAppItem.cpp Lines 1078 to 1083 in eb80b71
from
and was originally implemented in 2c6f1b6 |
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. |
* fix: alias cleanup #1350 * fix: item type string change from 1.1.2
Still problem exist.
|
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. |
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.The text was updated successfully, but these errors were encountered: