Project

General

Profile

Actions

Bug #1294

closed
JH

memory leak in Widget gallery

Bug #1294: memory leak in Widget gallery

Added by Jan Hrubeš over 14 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
Start date:
05/18/2012
Due date:
% Done:

0%

Estimated time:

Description

Hi,
in Widget gallery -> dialogs -> WDialog -> Non-modal dialog is a memory leak.
In customNonModal() is called a constructor of NonModalDialog.

void DialogWidgets::customNonModal()
{
   NonModalDialog *dialog = new NonModalDialog("Personalia (non-modal)", ed_);
   dialog->show();
}

It is just hidden after clicking a button.
There is no destruction of this object (and WDialog has parent=0).
Tho object remains in memory even after session destruction.

regards,
Jan

WD Updated by Wim Dumon over 14 years ago Actions #1

  • Status changed from New to Resolved

Fixed it in git by adding 'delete this' to the NonModalDialog::welcome().

Did you check (with valgrind or whatever tool) that this actually results in a memory leak? The dialog should still have been deleted on session terminatation.

Regards,
Wim.

JH Updated by Jan Hrubeš over 14 years ago Actions #2

Should be?
According to this memory question on session termination is deleted root of the widget tree a thus all children in that tree. But WDialog has no parent so it shouldn't be in widget tree.
I haven't use valgrind, but I am really curious what the behavior is.
I thought that when I create a widget *w with "new" and "parent=0", I should call delete w. The widget is not in widget tree unless I call some addWidget(w).
Thanks for clarification.

regards,
Jan

WD Updated by Wim Dumon over 14 years ago Actions #3

Jan,

Non-modal dialogs are inserted automatically in the widget tree. Their parent is some internal widget.

Best regards,
Wim.

JH Updated by Jan Hrubeš over 14 years ago Actions #4

Wim,
is this a specialty of non-modal dialogs or are there some other widgets with similar behavior? This hidden parent setting isn't mentioned in documentation, so I had thought that memory management with dialogs is programmers responsibility.
It sounds like, that everything that is rendered on a web page must be in widget tree.

regards,
Jan

WD Updated by Wim Dumon over 14 years ago Actions #5

Jan,

indeed everything that is rendered is somewhere in the widget tree.
I believe popup windows and the loading indicator are other examples.

Note that it's a good idea to delete your dialogs when you don't use them anymore, so in my opinion it's better to delete non-modal dialogs when you're no longer using them.

Regards,
Wim.

KD Updated by Koen Deforche about 14 years ago Actions #6

  • Status changed from Resolved to Closed
  • Target version set to 3.2.2

Released in Wt 3.2.2

Actions

Also available in: PDF Atom