Project

General

Profile

Actions

Bug #1294

closed

memory leak in Widget gallery

Added by Jan Hrubeš almost 12 years ago. Updated almost 12 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

Actions #1

Updated by Wim Dumon almost 12 years ago

  • 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.

Actions #2

Updated by Jan Hrubeš almost 12 years ago

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

Actions #3

Updated by Wim Dumon almost 12 years ago

Jan,

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

Best regards,

Wim.

Actions #4

Updated by Jan Hrubeš almost 12 years ago

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

Actions #5

Updated by Wim Dumon almost 12 years ago

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.

Actions #6

Updated by Koen Deforche almost 12 years ago

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

Released in Wt 3.2.2

Actions

Also available in: Atom PDF