[MGNLUI-1109] Apps that have opened modal dialogs remain in memory after they're closed Created: 12/Apr/13  Updated: 25/Jun/13  Resolved: 25/Jun/13

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 5.0
Fix Version/s: 5.0

Type: Bug Priority: Critical
Reporter: Tobias Mattsson Assignee: Aleksandr Pchelintcev
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
duplicates MGNLUI-1464 Possible Overlay leaks. Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled

 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);

Generated at Mon Feb 12 08:43:26 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.