74
Views
1
Comments
Getting rid of javascript garbage using window.gc() or win.gc()
Application Type
Reactive

Hello Everyone,

We are developing a single-page reactive app which constantly communicates with the server and updates parts of its screens using  the full calendar component. Updating can be as frequent as 1s.  During the updates, references to large amount's of JS objects are lost and those objects have to be cleaned by garbage collector eventually in order to prevent the performance from degrading. 

Refreshing the page or reloading the page is not an option.

We need to initiate garbage collection manually. So far  we have tried including the command window.gc() into a javascript node on the on initialise action of the page. But this throws an exception on service center:  window.gc() is not a function

How can I include the window.gc() command into a reactive app?

Thank you!

Monica

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi Monica,

If I recall correct one can only use window.gc() if the browser is running in some kind of debug/developer mode, setting a specific chrome flag. You would need to google that.

From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management

In think you better inspect the code and make sure eventhandlers etc that are allocated are also removed again.

Regards,

Daniel

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.