Release Memory used by Widgets
Added by Jason D almost 3 years ago
Hi,
I did a test as below,
- Add 10000 elements to page, I can see that memory size has been increased around 15Mb (with Mac activity monitor Private Memory Size)
- Remove all those 10000 elements with parent -> clear() method, the memory size has been decreased by less than 5MB.
- Recheck memory usage after 10 minutes, the memory size didn't drop.
- Add 10000 elements to page, again I can see that memory size has been increased around 13Mb
- Remove all those 10000 elements with parent -> clear() method, the memory size has been decreased by less than 3MB.
- Recheck memory usage after 10 minutes, the memory size didn't drop.
With this test result, it seems the memory cannot fully released by removing them, what d
My project has serious concerns over memory usage, any help on identifying the cause or releasing the memory size is very much appreciated, thanks in advance.
My test code:
button1 -> clicked().connect([ = ] {
for (int i = 0; i < 10000; i++) {
parent -> addWidget(Wt::cpp14::make_unique < Wt::WPushButton > ());
}
});
button2 -> clicked().connect([ = ] { parent -> clear(); });
Best Regards,
Jason Dong
Replies (4)
RE: Release Memory used by Widgets - Added by Plug Gulp almost 3 years ago
Would you be able to run valgrind[0] on your program? What does it report?
RE: Release Memory used by Widgets - Added by Jason D almost 3 years ago
Valgrind is not supported on my MacOC Monterey, tried 'leaks' but nothing detected.
RE: Release Memory used by Widgets - Added by Plug Gulp almost 3 years ago
Please could you try these: https://github.com/google/sanitizers
Here is the documentation: https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer
RE: Release Memory used by Widgets - Added by Roel Standaert almost 3 years ago
Perhaps what you're observing is not an actual leak in the program code, but the memory allocator not giving back the freed memory to the operating system.
You could use Valgrind's Massif heap profiler to see the actual memory usage by the application code over time on platforms where it is supported.
I think on a Mac you could use Instruments?