c++ - std::shared_ptr in QList does not delete content on deletion -
this question has answer here:
the following places bunch of shared_ptr
s containing arbitrary object in qlist. curly braces create stack, triggers deletion of list when instruction pointer leaves it. somehow shared_ptr
s not deleted. why? track memory consumption in gnome-systemmonitor , htop.
{ qlist<std::shared_ptr<qchar>> l; (int =0; i< 1024*1024*10; ++i) l.append(std::make_shared<qchar>('h')); } qdebug() <<"done"; sleep(10);
i tested it. same problem qsharedpointer, not regular types (non [shared] pointers).
small memory allocations come heap managed within process, not directly operating system. tools measure process's memory usage won't see them being deallocated, since memory still allocated process.
Comments
Post a Comment