Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-1109

Apps that have opened modal dialogs remain in memory after they're closed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Critical
    • 5.0
    • 5.0
    • None
    • None

    Description

      When an app opens a modal dialog its component is added as a child to MagnoliaShell. When the app is closed the component remains there. None of the object instances referenced by the dialog can be garbage collected making this a memory leak. The leaked instances include the entire app and all its sub apps.

      This also effects choose dialogs.

      This also effects dialogs open in a sub app when the sub app is closed. Also shell modal dialogs must have this problem although I have not tested it.

      Steps to reproduce:

      Log in to Admincentral
      Start the Pages app
      Edit /demo-features/content-templates/article
      Add a contact component
      In the dialog that pops up click "Select new..."
      Choose one of the contacts and save
      Close the Pages app

      Even though they're not displayed there's two modal dialogs in the component tree holding on to the closed Pages app.

      The component tree after this is:

         info.magnolia.ui.admincentral.AdmincentralUI
           info.magnolia.ui.vaadin.magnoliashell.MagnoliaShell
             info.magnolia.ui.vaadin.dialog.Modal
               info.magnolia.ui.contentapp.choosedialog.WorkbenchChooseDialogView
                 info.magnolia.ui.contentapp.browser.BrowserViewImpl
                   com.vaadin.ui.CssLayout
                     com.vaadin.ui.CssLayout
                       info.magnolia.ui.vaadin.grid.MagnoliaTreeTable
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                         com.vaadin.ui.Label
                     com.vaadin.ui.CssLayout
                       com.vaadin.ui.NativeButton
                       com.vaadin.ui.NativeButton
                       com.vaadin.ui.NativeButton
                     com.vaadin.ui.TextField
             info.magnolia.ui.vaadin.dialog.Modal
               info.magnolia.ui.vaadin.dialog.BaseDialog
                 info.magnolia.ui.vaadin.form.Form
                   info.magnolia.ui.vaadin.form.Form$1
                     info.magnolia.ui.vaadin.form.tab.MagnoliaFormTab
                       info.magnolia.ui.vaadin.form.FormSection
                         info.magnolia.ui.app.contacts.field.ContactTextAndButtonField
                           com.vaadin.ui.HorizontalLayout
                             info.magnolia.ui.form.field.TextAndButtonField
                               com.vaadin.ui.HorizontalLayout
                                 com.vaadin.ui.NativeButton
                                 com.vaadin.ui.TextField
                             info.magnolia.ui.app.contacts.field.ContactThumbnailField
                               com.vaadin.ui.HorizontalLayout
                                 com.vaadin.ui.Image
                                 com.vaadin.ui.Label
             info.magnolia.ui.vaadin.magnoliashell.viewport.AppsViewport
             info.magnolia.ui.vaadin.magnoliashell.viewport.ShellAppsViewport
               info.magnolia.ui.vaadin.applauncher.AppLauncher
      

      To print the component graph I added this piece of code in AdmincentralUI.init()

              new Timer(true).scheduleAtFixedRate(new TimerTask() {
                  @Override
                  public void run() {
                      System.out.println("== Vaadin component report");
                      int n = 0;
                      LinkedList<Component> stack = new LinkedList<Component>();
                      stack.add(AdmincentralUI.this);
                      while (!stack.isEmpty()) {
                          Component component = stack.removeFirst();
                          int depth = 0;
                          Component x = component;
                          while (x!= null) {
                              depth++;
                              x = x.getParent();
                          }
                          System.out.println(StringUtils.repeat("  ", depth) + " " + component.getClass().getName());
                          n++;
                          if (component instanceof HasComponents) {
                              HasComponents hc = (HasComponents) component;
                              for (Component next : hc) {
                                  stack.addFirst(next);
                              }
                          }
                      }
                      System.out.println("Total components: " + n);
                  }
              }, 30000, 10000);
      

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                apchelintcev Aleksandr Pchelintcev
                tmattsson Tobias Mattsson
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD