TAMULib / weaver-components

Custom Web Components for the Weaver UI
MIT License
0 stars 1 forks source link

Weaver Components Memory and Performance Concerns #428

Closed kaladay closed 3 years ago

kaladay commented 3 years ago

When using tamu-library-components, a notable memory leak and performance degradation is observed over time.

After idling for an extended period, such as a few hours, gigabytes of RAM end up being used and CPU ends up running up to 80% to 100%.

Preliminary investigation suggests problems with the garbage collection process. This problem is likely exposing problems in the clients, such as Firefox, or the dev tools.

The garbage collector seems to become aggresively executed more and more until it is just about always running. Investigate to see why this is happening and to keep the garbage collector from being overly aggresive.

Potentially relevant references from https://trungk18.com/experience/angular-common-memory-leak-use-case-observable/:

Memory leaks most often arise over time when components are re-rendered multiple times, e.g through routing or by using the *ngIf directive, or...

and

The easiest way to fix the problem above is to clean the subscription when you destroy the component, or when you don't need it anymore.

ngOnDestroy() {
    this.counterSubscription.unsubscribe();
}