QWidget subclass leak memory-
-
I don't know if you know, that Windows CE does not close your application if you close your window. The Flags you set don't influence this behavior.
Edt: I've developed an CE application that quits on close. I'll have a look at it and post some code, if that is what you need.
-
[quote author="MichelS" date="1348474193"]I don't know if you know, that Windows CE does not close your application if you close your window. The Flags you set don't influence this behavior.
Edt: I've developed an CE application that quits on close. I'll have a look at it and post some code, if that is what you need.[/quote]
can be this the cause of the leak ? But still all the destructors are invoked. Do you have any tool to perform memory analysis on Windows CE?
-
[quote author="author="blackbelt" date="1348475013"]
can be this the cause of the leak ?
[/quote]
I won't call it a "leak", cause it's expected behavior to have the applications running in the background until other applications need that memory.[quote author="author="blackbelt" date="1348475013"]But still all the destructors are invoked.
[/quote]
That's kind of strange. Do you pass the point after application.exec(); in your main()?
Is the process still running?
[quote author="author="blackbelt" date="1348475013"]
Do you have any tool to perform memory analysis on Windows CE?[/quote]
Maybe. You can try "Visual Leak Detector":http://vld.codeplex.com/ I don't know if this works for CE. -
bq. I won’t call it a “leak”, cause it’s expected behavior to have the applications running in the background until other applications need that memory.
I see, but Still, If my MainWindow shows this widget, when I close it, should all the momory allocated return to the system?
-
I use a QPixmap as Background Image but I allocate in on the stack. Should I take care of the QPixmap?
-
[quote author="blackbelt" date="1348478095"]I use a QPixmap as Background Image but I allocate in on the stack. Should I take care of the QPixmap?[/quote]
No. Items allocated on the stack are automatically deleted once they go out of scope. -
Try to use Qt's parent/child mechanism. That will automatically delete the child widgets. You can use it in the ctor or you can use it later with the .setparent() function. And if you have some layout, your widgets will be reparented automatically. Means: If the parent widget is go out of scope, your child widgets will be deleted without any intervention.
-
[quote author="broadpeak" date="1348479649"]Try to use Qt's parent/child mechanism. That will automatically delete the child widgets. You can use it in the ctor or you can use it later with the .setparent() function. And if you have some layout, your widgets will be reparented automatically. Means: If the parent widget is go out of scope, your child widgets will be deleted without any intervention.[/quote]
Only, QPixmap is not a QObject, and thus this mechanism can't be used here. -
[quote author="Andre" date="1348479951"]
[quote author="broadpeak" date="1348479649"]Try to use Qt's parent/child mechanism. That will automatically delete the child widgets. You can use it in the ctor or you can use it later with the .setparent() function. And if you have some layout, your widgets will be reparented automatically. Means: If the parent widget is go out of scope, your child widgets will be deleted without any intervention.[/quote]
Only, QPixmap is not a QObject, and thus this mechanism can't be used here.
[/quote]How can be a pixmap on stack memory leaked?
Anyway, in WinCE with the close button you can't close the app, only put it in the background. If somebody would like to close the app, it can be made only with a button direct for this purpose (QCloseEvent, event->accept();).
-
If i recall that correctly you should react on the top-level window's OnHide event to shut your application manually down using @QCoreApplication::exit()@.
-
bq. (QCloseEvent, event->accept();).
I already do that. If In my QWidget subclass I do not assign a parent (I call the super constructor with NULL as parameter), should I care to free all the memory allocated?
-
[quote author="blackbelt" date="1348483366"]bq. (QCloseEvent, event->accept();).
I already do that. If In my QWidget subclass I do not assign a parent (I call the super constructor with NULL as parameter), should I care to free all the memory allocated?[/quote]
Yes. Every object what is created with new and has no parent (who is responsible for cleaning) must be deleted with the delete operator. If an object is created on the stack or has some parent relation, will be deleted by the system.