Since Loomio creates dynamic views every time a user navigates to new pages, this behavior results in a measurable memory leak.
Methodology
See #4247. For the base case here, I fixed the ment.io leaks.
Here are the fixes I made. They are likely not what you want to do to fix the behavior indefinitely, but they worked for the purpose of measuring the leak impact. It should be noted that LokiJS does not complain if you try to remove a dynamic view that does not exist.
Background
Loomio's angular frontend uses LokiJS Dynamic Views for a variety of tasks. Loomio created these dynamic views by calling
addDynamicView
on a collection. Internally, LokiJS appends new dynamic views to an array and returns it to Loomio. LokiJS expects that Loomio will later callremoveDynamicView
with the name of the dynamic view to remove the dynamic view instance from this internal array, but Loomio does not do this.Since Loomio creates dynamic views every time a user navigates to new pages, this behavior results in a measurable memory leak.
Methodology
See #4247. For the base case here, I fixed the
ment.io
leaks.Here are the fixes I made. They are likely not what you want to do to fix the behavior indefinitely, but they worked for the purpose of measuring the leak impact. It should be noted that LokiJS does not complain if you try to remove a dynamic view that does not exist.
core/services/thread_query_service.coffee
: FixingLoomio.records.discussions.collection
core/models/poll_option_model.coffee
: FixingLoomio.records.stanceChoices.collection
core/models/comment_model.coffee
: FixingLoomio.records.versions.collection
Results
Loomio leaks ~140 kilobytes (KB) every time the user navigates to a few pages.
Suggestions
Refactor your code to appropriately clean up dynamic views when they are no longer needed.
The text was updated successfully, but these errors were encountered: