jcassee/angular-hypermedia

HalResources not cleared in ResourceContext

Closed this issue · 5 comments

Hi,

I'm solving memory issues in our application. One of the issues is the ever growing size of the ResourceContext.

After creating a ResourceContext, and clicking through our application the number of resources is growing rapidly. The number of resources is only increasing and never decreasing.
Is there a way to cleanup unused resources?

I also tried to put the resources in different ResourceContexts, but that didn't solve my issues either.

In the screenshot, there is 1 ResourceContext with 1216 resources.

screen shot 2018-01-22 at 11 16

See the attached screenshot for details.

Yes, this is by design and the whole reason d'etre of the ResourceContext object: resource scope management. The idea is to scope a context to a "unit of work" that loads a set of related resources. I would advise creating a context in the resolve function of the view. (Might be a parent view used by a set of related subviews, of course.)

Does that help?

Thanks, but it doesn't solve our issue.

When we use different ResourceContexts, none of these contexts are cleared. The total number of resources in these contexts isn't lower compared to one ResourceContext.
Do you know why the resources are not removed? I suppose that not-used resources should be removed from the context automatically?

Do you keep references to either the context or its resources? The assumption is that, say, when the user navigates away from a view that had a context defined in its resolve function, no other parts of the application keeps references to that context or its resources.

Thanks, yes, that's how we did it. But there's still something in our application that has a reference to these resources. We are still searching for the root cause, but the angular-hypermedia modules works as expected.
Thanks for your fast response.

Tracking references in JavaScript can be a bit of a pain. :-( I hope you work it out. I'll close this ticket. Feel free to reopen if you discover angular-hypermedia is not doing what it is supposed to do after all.