true-di
githubnpm
  • Introduction
  • Core
    • diContainer
    • multiple
    • isReady
    • prepareAll
    • releaseAll
    • factoriesFrom
  • Utils
    • assignProps
    • shallowMerge
  • Recipes
    • Accessing Items
    • Releasing Items
    • Creating All Items
    • Cyclic Dependencies
    • Injection Context
    • Creating Factories before Container
Powered by GitBook
On this page

Was this helpful?

  1. Recipes

Releasing Items

No memory leaks more.

PreviousAccessing ItemsNextCreating All Items

Last updated 4 years ago

Was this helpful?

To tackle possible memory leaks issues true-di allows to control what items are stored in the container. It doesn't allow to replace items, but it allows to unbind it from the container (release item).

To do that just assign the correspondent container property with null or undefined (don't try to delete it).

container.logger = null;

It doesn't affect other already created items those are depent on it. They continue to use previously created item.

When you need to release all items from the container use function:

releaseAll(container);
releaseAll