ionic-team/stencil-store

bug: Memory leak

raymondboswel opened this issue · 4 comments

Prerequisites

Stencil Store Version

2.0.3

Stencil Version

2.22.2

Current Behavior

Nodes aren't garbage collected when using stencil/store.

Expected Behavior

Nodes should get garbage collected.

Steps to Reproduce

Clone https://github.com/raymondboswel/stencil-redux-example
In terminal a: cd mock-server; node server.ts
In terminal b: npm run start

Open performance monitor, and memory tab. Trigger garbage collector. Take note of nodes count.

Spam click 'Toggle RxJS Todos' button. Trigger garbage collector. Take note of nodes count.

Spam click 'Toggle Stencil/store Todos' button. Trigger garbage collector & notice that nodes count does not decrease.

Code Reproduction URL

https://github.com/raymondboswel/stencil-redux-example

Additional Information

No response

Also something ive noticed is that when you add an onChange inside of a component, that reference is being saved and causing detatched elements to stay on the pages. This would be something good to look into.

Hey @raymondboswel 👋

Thanks for the reproduction case! Would it be possible to try to reduce the scope of this reproduction case such that it only uses @stencil/core and @stencil/store? At the moment, the repro is a little too big for someone to try to wade through in order to perform root cause analysis. Thanks!

@rwaskiewicz I created a new repo from the same codebase.
RTKQuery was removed from the flow of the memory leak reproduction. I left the peripheral
code for reference as an example of essentially the same code without a leak. You only need to look at
app-stencil-store-todos.tsx and follow the data flow as initiated in the component (service -> store -> component).

I've also narrowed the source of the leak down somewhat, though I still don't know why it would leak. See
app-stencil-store-todos.tsx:16

https://github.com/raymondboswel/stencil-store-memory-leak

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.

Thank you for using Stencil Store!