simonkrauter / NiGui

Cross-platform desktop GUI toolkit written in Nim
MIT License
724 stars 49 forks source link

Is it a bug (increasing ram consumption indefinitely) #175

Closed Sznymo closed 1 year ago

Sznymo commented 1 year ago

I noticed that when deleting button,etc.... ram consumption keeps increasing , so I ran a test (below its code and result). After starting the code was eating 37.9 mb After a few clicks 39.1 mb When there are many entries or buttons the ram consumption increases a lot . Is there a way to fix this ?

Code Test: _import nigui app.init() var window = newWindow("Test") window.width = 600.scaleToDpi window.height = 400.scaleToDpi var container = newLayoutContainer(LayoutVertical) window.add(container) var button = newButton("Button Test Remove") container.add(button) button.onClick = proc(event: ClickEvent) = container.remove(button) container.add(button) window.show() app.run()

test

simonkrauter commented 1 year ago

Are you running it under Linux/Gtk? I have looked in the code of the remove and add methods, but I don't see anything which allocates memory.

Sznymo commented 1 year ago

Yes Linux/Gtk, this is how I add in the test button and remove it. Deleting does not release ram memory :/ there is no longer a button but still memory is taken. Similarly, deleting anything else in NiGui does not free up ram memory. (I tested on several hardware configurations and 3 Linux distributions)

simonkrauter commented 1 year ago

Good news: I have found and fixed several memory leaks (https://github.com/simonkrauter/NiGui/commit/aa5908519eff9b9e80d0633be955f3744c64fef9). At least with your example I don't see any more that the memory usage goes up. If you still have such a problem, please re-open or create a new issue.