Skip to content

Store causing huge memory retention and cleanup takes forever #573

@anshul-kai

Description

@anshul-kai

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:

  1. 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.
  2. 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.
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions