ngx-bootstrap icon indicating copy to clipboard operation
ngx-bootstrap copied to clipboard

Memory leak on ngx bootstrap modal component

Open rahulz-wasnik opened this issue 4 years ago • 8 comments

Bug description: This is infact a simpler version of the example used to open a component using ngx bootstrap modal given under the component section on this link. https://valor-software.com/ngx-bootstrap/#/modals

In my example I am using the ngx bootstrap modal to open a Confirm Component. Open the StackBlitz in chrome and under the developer tools, navigate to the memory tab and take a heap snapshot without clicking on the open button. Now click the open button 3 times and take a heap snapshot again. Compare the two snapshots and search for ConfirmComponent, ModalBackdropComponent and ModalContainerComponent. There are 3 instances of each. These keep increasing in count as the open button is clicked. Even if the garbage collection is run they are not deleted.

Also the number of detached html elements keep on increasing in size with every click.

StackBlitz that reproduces the issue: https://stackblitz.com/edit/angular-ivy-17kffn https://angular-ivy-17kffn.stackblitz.io/

rahulz-wasnik avatar Dec 19 '20 13:12 rahulz-wasnik

Hi,

Thanks for opening this issue @rahulz-wasnik!

We are also impacted by this memory leak in our app. Version 6.0.0 of ngx-bootstrap looks not to be affected, only 6.1.0 & 6.2.0 are.

Context:

  • ngx-bootstrap 6.1.0 & 6.2.0
  • Angular 11

I'd be happy to help fixing it, don't hesitate to ask if you guys need more informations / testing.

Thank you!

bravier avatar Jan 04 '21 10:01 bravier

Thank you. Yeah it be good to have this fixed in 6.1.0 & 6.2.0.

rahulz-wasnik avatar Jan 11 '21 01:01 rahulz-wasnik

Hi, any news on this issue? We are affected by this issue as well, can provide a PR if that helps :)

derfritz avatar Jan 12 '21 10:01 derfritz

We're interested in having this fixed as well. https://github.com/valor-software/ngx-bootstrap/issues/5971#issuecomment-732296449

dianabarsan avatar Jan 28 '21 05:01 dianabarsan

@derfritz that will be awesome !

daniloff200 avatar Feb 05 '21 16:02 daniloff200

Any update on this or even a workaround?

nielswitte avatar Dec 03 '21 10:12 nielswitte

The issue still persists. Any dialog open is a leak.

sherlock1982 avatar Nov 15 '22 14:11 sherlock1982

Any news about this? Still happening:

image

It only takes is a simple script like this to flood memory with duplicate instances:

let i = 0;
for (let t of Array(30).fill('')) {
    setTimeout(() => {
        document.querySelector('demo-modal-service-component button').click();
        setTimeout(() => document.querySelector('.modal.fade.show .modal-header .btn-close').click(), 250);
    }, 350 * i);
    i++;
}

cgcdoss avatar May 05 '23 00:05 cgcdoss