[Qt/C++] Gestione Memoria
#41
Posted 05 August 2011 - 21:45
#42
Posted 06 August 2011 - 19:35
E comincia a piacerti, eh ?
Boia si
Oggi non ho avuto molto tempo ma fatto parecchi progressi, e ho risolto tutti i memory leak
FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
Mai più giorni felici
#43
Posted 06 August 2011 - 20:09
Boia si
Oggi non ho avuto molto tempo ma fatto parecchi progressi, e ho risolto tutti i memory leak [/quote]
Visto che sei su Linux, usa valgrind
#44
Posted 07 August 2011 - 14:14
Visto che sei su Linux, usa valgrind@[/url]":3ga1wpiv]
Boia si
Oggi non ho avuto molto tempo ma fatto parecchi progressi, e ho risolto tutti i memory leak
sta installando, fino a, mentre mia madre succhia cazzi, ora andavo "a naso" con il cosino che ti segna la memoria occupata di netbeans (inb4 è scritto in java)
domanda veloce: se aggiungo un layout ad un layout con addLayout() viene automaticamente impostato il layout "padre" come padre del layout "figlio"? O per sicurezza passo sempre il layout padre nel costruttore?
FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
Mai più giorni felici
#45
Posted 07 August 2011 - 14:19
==28644== LEAK SUMMARY: ==28644== definitely lost: 3,006 bytes in 47 blocks ==28644== indirectly lost: 7,388 bytes in 388 blocks ==28644== possibly lost: 428,725 bytes in 2,376 blocks ==28644== still reachable: 808,054 bytes in 7,972 blocks ==28644== suppressed: 0 bytes in 0 blocks
FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
Mai più giorni felici
#46
Posted 07 August 2011 - 16:23
domanda veloce: se aggiungo un layout ad un layout con addLayout() viene automaticamente impostato il layout "padre" come padre del layout "figlio"? O per sicurezza passo sempre il layout padre nel costruttore?
cazzo, per esempio devo inserire un QFormLayout dentro a un QVBoxLayout, ma non posso passargli il QVBoxLayout nel costruttore, in quanto accetta solo QWidget*, e non posso passare la QWidget su cui sto lavorando perché a runtime darebbe errore in quanto il widget ha già un layout (e la finestra sarebbe tutta sballata)... wat do?
ovviamente posso istanziarlo senza parent ma questo dovrebbe causare un memory leak, in quanto quando il widget muore viene deallocato il QVBoxLayout ma non il QFormLayout
La cosa ideale sarebeb che l'addLayout si autoarrangi a settare il parent, ma non ho trovato niente sulla documentazione.
FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
Mai più giorni felici
#47
Posted 07 August 2011 - 16:48
FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
Mai più giorni felici
#48
Posted 08 August 2011 - 08:20
Se ti va metti l'output di:hmmm
==28644== LEAK SUMMARY: ==28644== definitely lost: 3,006 bytes in 47 blocks ==28644== indirectly lost: 7,388 bytes in 388 blocks ==28644== possibly lost: 428,725 bytes in 2,376 blocks ==28644== still reachable: 808,054 bytes in 7,972 blocks ==28644== suppressed: 0 bytes in 0 blocks
valgrind -v --show-reachable=yes --leak-check=full
#49
Posted 08 August 2011 - 08:23
Non so se ho capito bene ma la doc dice questo:
@[/url]":3tdquj95]
domanda veloce: se aggiungo un layout ad un layout con addLayout() viene automaticamente impostato il layout "padre" come padre del layout "figlio"? O per sicurezza passo sempre il layout padre nel costruttore?
cazzo, per esempio devo inserire un QFormLayout dentro a un QVBoxLayout, ma non posso passargli il QVBoxLayout nel costruttore, in quanto accetta solo QWidget*, e non posso passare la QWidget su cui sto lavorando perché a runtime darebbe errore in quanto il widget ha già un layout (e la finestra sarebbe tutta sballata)... wat do?
ovviamente posso istanziarlo senza parent ma questo dovrebbe causare un memory leak, in quanto quando il widget muore viene deallocato il QVBoxLayout ma non il QFormLayout
La cosa ideale sarebeb che l'addLayout si autoarrangi a settare il parent, ma non ho trovato niente sulla documentazione.
http://doc.qt.nokia....est/layout.html
Tips for Using Layouts
When you use a layout, you do not need to pass a parent when constructing the child widgets. The layout will automatically reparent the widgets (using QWidget::setParent()) so that they are children of the widget on which the layout is installed.
Note: Widgets in a layout are children of the widget on which the layout is installed, not of the layout itself. Widgets can only have other widgets as parent, not layouts.
You can nest layouts using addLayout() on a layout; the inner layout then becomes a child of the layout it is inserted into.
#50
Posted 08 August 2011 - 09:56
Non so se ho capito bene ma la doc dice questo:@[/url]":3ombos84]
cazzo, per esempio devo inserire un QFormLayout dentro a un QVBoxLayout, ma non posso passargli il QVBoxLayout nel costruttore, in quanto accetta solo QWidget*, e non posso passare la QWidget su cui sto lavorando perché a runtime darebbe errore in quanto il widget ha già un layout (e la finestra sarebbe tutta sballata)... wat do?
ovviamente posso istanziarlo senza parent ma questo dovrebbe causare un memory leak, in quanto quando il widget muore viene deallocato il QVBoxLayout ma non il QFormLayout
La cosa ideale sarebeb che l'addLayout si autoarrangi a settare il parent, ma non ho trovato niente sulla documentazione.
http://doc.qt.nokia....est/layout.htmlTips for Using Layouts
When you use a layout, you do not need to pass a parent when constructing the child widgets. The layout will automatically reparent the widgets (using QWidget::setParent()) so that they are children of the widget on which the layout is installed.
Note: Widgets in a layout are children of the widget on which the layout is installed, not of the layout itself. Widgets can only have other widgets as parent, not layouts.
You can nest layouts using addLayout() on a layout; the inner layout then becomes a child of the layout it is inserted into.
sisi l'avevo già letto ma non parlo dei widget, parlo proprio dell'oggetto layout. comunque ho risolto con setLayout() dai
FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
Mai più giorni felici
#51
Posted 08 August 2011 - 09:57
Ah, btw:
valgrind --leak-check=full --show-reachable=yes -v ls -l
==2776== LEAK SUMMARY:
==2776== definitely lost: 200 bytes in 3 blocks
==2776== indirectly lost: 240 bytes in 20 blocks
==2776== possibly lost: 0 bytes in 0 blocks
==2776== still reachable: 13,458 bytes in 46 blocks
==2776== suppressed: 0 bytes in 0 blocks
==2776==
==2776== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 32 from 9)
#52
Posted 08 August 2011 - 10:00