Jump to content


Photo

[Qt/C++] Gestione Memoria


This topic has been archived. This means that you cannot reply to this topic.
51 replies to this topic

#41 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 05 August 2011 - 21:45

E comincia a piacerti, eh ? :patpat:
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#42 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44144 posts

Posted 06 August 2011 - 19:35

E comincia a piacerti, eh ? :wink:


Boia si :whistler:

Oggi non ho avuto molto tempo ma fatto parecchi progressi, e ho risolto tutti i memory leak :whistler:

FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
 

Mai più giorni felici


#43 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 06 August 2011 - 20:09

[quote name="toyo @":dc2vtvus] [quote name='"trallallero"]E comincia a piacerti' date=' eh ? :wink:[/quote']

Boia si :whistler:

Oggi non ho avuto molto tempo ma fatto parecchi progressi, e ho risolto tutti i memory leak :whistler:[/quote]
Visto che sei su Linux, usa valgrind :shock:
Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#44 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44144 posts

Posted 07 August 2011 - 14:14

@[/url]":3ga1wpiv]

Boia si :asd:

Oggi non ho avuto molto tempo ma fatto parecchi progressi, e ho risolto tutti i memory leak :asd:

Visto che sei su Linux, usa valgrind :v


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 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44144 posts

Posted 07 August 2011 - 14:19

hmmm :asd:

==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 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44144 posts

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 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44144 posts

Posted 07 August 2011 - 16:48

Risolto usando insertlayout() al posto di addlayout(), almeno questo sono sicuro che layout becomes a child of the box layout. :asd:

FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
 

Mai più giorni felici


#48 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 08 August 2011 - 08:20

hmmm :asd:

==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

Se ti va metti l'output di:
valgrind -v --show-reachable=yes --leak-check=full

Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#49 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 08 August 2011 - 08:23

@[/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.

Non so se ho capito bene ma la doc dice questo:

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.


Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#50 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44144 posts

Posted 08 August 2011 - 09:56

@[/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.

Non so se ho capito bene ma la doc dice questo:

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.


sisi l'avevo già letto ma non parlo dei widget, parlo proprio dell'oggetto layout. comunque ho risolto con setLayout() dai :asd:

FIRMA FOTTUTAMENTE EDITATA. IL FOTTUTO STAFF.
 

Mai più giorni felici


#51 trallallero

trallallero

    Schiavo

  • Membri
  • PipPipPipPipPipPipPip
  • 16188 posts

Posted 08 August 2011 - 09:57

Meglio così.

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)


Don't worry, faith will come soon, like a recall but,
if you can't wait, just stop thinking at all 

 


#52 toyo

toyo

    sono triste

  • Donatori di sperma
  • PipPipPipPipPipPipPip
  • 44144 posts

Posted 08 August 2011 - 10:00

Sono su aifon ora, dopo lo faccio :asd: