Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dgrid in dijit/layout/stackcontainer not being properly destroyed - possible memoryleak #1318

Closed
gerpres opened this issue Oct 18, 2016 · 3 comments · Fixed by #1464
Closed

Comments

@gerpres
Copy link

gerpres commented Oct 18, 2016

if the StackContainer is being destroyed, it tries to destroy it's children too - unfortunately it calls 'removeChild(child)' before destroying it - the dgrid cleanup mechanism doesn't work any more, because

document.getElementById(id)

doesn't find the row, because it's not part of the DOM anymore.
therefore removeRow() is not called and if you use widgets in your rows, those widgets may not be destroyed.

any ideas how to solve this?

@gerpres
Copy link
Author

gerpres commented Oct 18, 2016

I replaced the

byId(id)

in

List.cleanup()

with following code

query("[id="+miscUtil.escapeCssIdentifier(i)+"]",this.domNode).forEach(function(rowElement) {
    if(rowElement){
        self.removeRow(rowElement, true);
    }
});

to make destroy work again.
I couldn't use CSS's #id selector - may access the document-id-mapping too 👎

@kfranqueiro
Copy link
Member

Interesting. Example repro from test page:

  1. Load http://dgrid.io/js/dgrid/test/dijit_layout.html
  2. require('dojo/aspect').before(require('dgrid/List').prototype, 'removeRow', function(){ console.log('removeRow'); })
  3. dijit.byId('tc').destroyRecursive()

OTOH, if you were to call destroyRecursive on the BorderContainer (bc) instead, you'd see 25 removeRow calls logged for the grid in the left sidebar.

@gerpres
Copy link
Author

gerpres commented Oct 19, 2016

that's the problematic code...

dijit/layout/StackContainer

destroyDescendants: function(/*Boolean*/ preserveDom){
            this._descendantsBeingDestroyed = true;
            this.selectedChildWidget = undefined;
            array.forEach(this.getChildren(), function(child){
                if(!preserveDom){
                    this.removeChild(child);
                }
                child.destroyRecursive(preserveDom);
            }, this);
            this._descendantsBeingDestroyed = false;
        }

it removes the children before destroying them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants