You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an extremely large application (over 40k lines of code) which heavily relies on backbone relational. Using backbone relational has certainly come in handy in many regards but we are soon realizing that there seems to be a huge price to pay for large applications. I'm writing this with the hopes that my realization is wrong.
One of our bigger Models often ends up in a Tree structure with over 10k child nodes. This Tree has more than 10 levels of nestings with each child node representing a unique Model or a Collection. The problem at hand is a major memory retention that happens due to the Store.
Following are the approaches I've tried with results noticed:
Perform a deep cleanup - Iterate through the whole Tree calling Backbone.Relational.store.unregister on each model. This works but sometimes takes minutes to complete which is completely unacceptable from a user experience perspective.
Backup the Store before loading the Tree and restore it to its original state. I've also tried unregistering all new Collections inspired by the Store.reset function. This approach seems to work unreliably and seems extremely hacky.
Introducing a new scope by using addModelScope and removeModelScope. This seems to have no affect and if my understanding is correct, the model scope is set only for definitions and not instances.
Is there no graceful way to perform a memory cleanup?
The text was updated successfully, but these errors were encountered:
This doesn't solve your problem, but I had the same issue.
Backbone relational started off as a nice feature that sped up development, but quickly became a bog on performance. Over the last couple of years I've migrated all my collections and models to my own plugin that helps manage relations between collections and models.
@a-koka I know this is an old issue, but one thing that REALLY helped for us, was to set the "includeInJSON" attribute of the reverseRelation to false. It is default by true, which was causing a super crazy large nested object as we used the toJSON method when setting up data for our views.
We went from 2.5GB of RAM for this one larger page, to 30MB.... that's how crazy the nested-ness can get.
I have an extremely large application (over 40k lines of code) which heavily relies on backbone relational. Using backbone relational has certainly come in handy in many regards but we are soon realizing that there seems to be a huge price to pay for large applications. I'm writing this with the hopes that my realization is wrong.
One of our bigger
Models
often ends up in aTree
structure with over10k child nodes
. ThisTree
has more than10 levels of nestings
with each child node representing a uniqueModel
or aCollection
. The problem at hand is a major memory retention that happens due to theStore
.Following are the approaches I've tried with results noticed:
Tree
callingBackbone.Relational.store.unregister
on each model. This works but sometimes takes minutes to complete which is completely unacceptable from a user experience perspective.Store
before loading theTree
and restore it to its original state. I've also triedunregistering
all newCollections
inspired by theStore.reset
function. This approach seems to work unreliably and seems extremely hacky.addModelScope
andremoveModelScope
. This seems to have no affect and if my understanding is correct, themodel scope
is set only fordefinitions
and notinstances
.Is there no graceful way to perform a memory cleanup?
The text was updated successfully, but these errors were encountered: