Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling singletons in creation of large plans #373

Open
vikram-cf opened this issue Aug 1, 2019 · 3 comments
Open

Handling singletons in creation of large plans #373

vikram-cf opened this issue Aug 1, 2019 · 3 comments

Comments

@vikram-cf
Copy link

We have a complex application with a huge dependency graph. On startup, when all controllers are initialized at once using inversify-express-utils (container.getAll for controllers) we noticed that the startup takes upward of 5 minutes, with more than 6 GB of memory taken for the plan graph. Most of our bindings are Singleton.

Expected Behavior

container.getAll() should be fast

Current Behavior

container.getAll() takes > 5 minutes, a huge amount of RAM

Possible Solution

in planner.ts, we do not need to create childRequests for singleton Bindings multiple times, as there will be only instance of the object
Will be updating the issue with a pull request

Steps to Reproduce (for bugs)

  1. Application with a large dependency graph
  2. container.get() an object which is dependent on the full dependency graph

Context

Speeds up the startup of our application, and reduces startup memory utilization from ~6.5 GB to 600MB

Your Environment

node v11.13.0
inversify 5.0.1
inversify-express-utils 6.3.2
express 4.16.2

Private repo

Stack trace

None

@vikram-cf
Copy link
Author

Related Pull request: inversify/InversifyJS#1116

@vikram-cf
Copy link
Author

The fix seems to be having some issues with circular dependencies, trying to fix.

@vikram-cf
Copy link
Author

My approach( caching during the planning phase) seems to cause issues with dynamic bindings. Closing the PR

@PodaruDragos PodaruDragos transferred this issue from inversify/InversifyJS Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant