Comments (7)
please explain to me how lazy singletons prevent memory leeaks
from get_it.
If I have a big app, with 100 Singletons, then if I don't use lazy Singleton factories, they will all be created as soon as the app starts. Many of those Singletons might only be useful on some parts of the app, parts that the user might not even use. With lazy singletons only the Singletons that are requested will be created and live in memory, thus reducing the memory footprint.
from get_it.
from get_it.
That is true, but IMHO you take 1000s of Dart objects to get into memory troubles. Images are always the problem, not simple objects.
Yeah, but how do you know those singletons will always be simple objects? IMHO get_it
is a lib for locating services, creating objects, it's up to the user to choose what the objects look like, get_it
wasn't made just for simple objects.
You agree with me that it can happen, you gave me examples when this is possible to happen, so why not make get_it
better support those scenarios? This is a very popular library, used by many different apps, specially very big ones, that are the ones facing this problem. Saying that get_it
shouldn't be used for scenarios where we have 1000s of objects if the same as saying that get_it
is only recommended for small and simple apps, which I don't think it's the case.
from get_it.
you also have to keep in mind, that I maintain several packages as the sole maintainer in my spare time. So I have to focus on feature requests that help a large group of my users and you are the first one since this package exists (and it's one of the oldest on pub) so it really doesn't seem to be a problem for the majority of my users.
if this issue get more likes I will consider it but it's not a trivial change
from get_it.
I think that's a fair point and I agree with you, my suggestion should not be dismissed based on personal opinions, but on technical matter, and should be implemented on a priority basis.
from get_it.
First, I want to say I really like the package and appreciate the work that is put into packages like get_it. Thanks!
Second, I would also appreciate such an enhancement. For my use-case, it's mainly that some singletons should be started in a specific order (which I can do with regular singletons and async ones, but not lazy singletons or even lazy async singletons) where they only work properly if some others are already setup (classic dependencies are API services, storage services and so on). In order to not overload everything on startup it would be nice to have the lazy loading feature in that situation as well.
from get_it.
Related Issues (20)
- [Feature Request] Ability to verify getIt configuration
- getIt.reset() should dispose Singletons in reverse registration order HOT 4
- [Feature] Option for ignoreReassignment HOT 5
- The license page is wrong with certain fonts. HOT 3
- Null check operator used on a null value. Error thrown Instance of 'ErrorDescription'. HOT 3
- Make a lazy `registerSingletonWithDependencies` HOT 5
- Async factorties should have a `dependsOn` HOT 20
- `registerLazySingletonAsync` not working with `dependsOn` HOT 3
- Add new type of scope that is independ of the scope stack HOT 1
- Build error in version 7.6.1 HOT 7
- unlisted from pub.dev? HOT 4
- Null check operator used on a null value with allReady on hot refresh HOT 2
- Can't register AutoRoute v6 with GetIt HOT 2
- Bad state: GetIt: Object/factory with type AdviceRepoImpl is not registered inside GetIt. HOT 1
- Check implementation of `WillSignalReady` on subclasses HOT 1
- Collections Multibinding HOT 5
- Questions about the registerFactory HOT 2
- Error on example code for addListener HOT 10
- Concerns about Get_It HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from get_it.