Memory is not full released after deleting all QPushButtons in QTApp
-
i am creating a program containing QPushButtons, the Problem is when i am adding QPushButtons memory(RAM) increasing but when i deleted all added buttons memory is not fully releasing.
void TempTest ::addSLOT() { li= new QList<QPushButton*>; for(int i=0;i<50000;i++) { QPushButton *p = new QPushButton; p->setText("sample"); p->setFixedSize(100,100); li->append(p); } } void TempTest ::removeSLOT() { while(li->count()) { QPushButton*p= li->at(0); li->removeAt(0); delete p; } delete li; }
1.initialy memory is 2.0 mb
2.after adding memory increased to 49.3 mb
3.after deleting memory decreased to 4.1 mb
there is 2.1 mb of RAM it never released
-
thanks for replying @BjornW
further if i repeat same process -
again add and delete Buttons - 4.4 mb
again add and delete Buttons - 4.9 mb
again add and delete Buttons - 4.6 mb
again add and delete Buttons - 4.4 mb
again add and delete Buttons - 5.4 mb
again add and delete Buttons - 4.9 mb
again add and delete Buttons - 4.6 mb -
@asimfile said in Memory is not full released after deleting all QPushButtons in QTApp:
it seems OS is resposible for memory loss
You misunderstood. The OS is responsible for memory management. C++ is a stack based language (following ASM's
push
andpop
), everything you allocate on the heap is managed by the OS's heap manager - that's its purpose (small wonder the heap allocation in C is a function). In any case, if you need to make sure you don't leak things, just use a code analyzer.