Infinite List Questions, Memory Usage
See original GitHub issueHi WatermelonDB developers. Wanted to ask about WatermelonDB usage with an infinite list. I understand that WatermelonDB is lazy first, would I be able to lazily load results of a query until the items are on screen. Wondering if watermelon DB supports something like this using RxJS
$items = $scrollPositionStream.switchMap(postion => runQueryForPosition(position))
Where I have only those objects which are on screen in memory (or those which have appeared on screen once)
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (15 by maintainers)
Top Results From Across the Web
How to limit memory usage of a lis… | Apple Developer Forums
Basically, I want to display an list of images with an infinite scroll but I want to keep the memory usage reasonable. I...
Read more >Flutter infinite/long list - memory issue and stack overflow error
I wrote some sample code for a related question about paginated scrolling, which you could check out. I didn't implement cache invalidation ...
Read more >ulimit not limiting memory usage - Super User
@Gilles: I've tried putting additional constrains on "max memory size", "virtual memory", "core file size", "data seg size", basically everything I can see...
Read more >Memory usage - Advanced R. - Hadley Wickham
This doubly-linked list makes it easy for internal R code to loop through every object in memory. A pointer to the attributes (8...
Read more >How is the memory used increasing by using an infinite loop?
A plain infinite loop consumes CPU cycles, not increasing amounts of memory. If you have a process with an infinite loop, and its...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Kenneth-KT You’re right, my suggested workaround has real flaws, which depending on the exact use case may be fatal. To be clear: I’m not against adding SQL-level limiting/ordering to WatermelonDB, I just don’t need it for my use cases, so I’m not going to drive the implementation of it. But if this is key to you, I would highly encourage you to consider contributing those, even in a limited form. I can offer guidance. And yes, @azizhk’s PR is another useful workaround for large lists. Using raw SQL queries is also a great option, if you have a good way to know when to trigger re-fetch. Yes, records fetched using SQL are still 🍉 objects and you can observe them normally.
@azizhk
None.
Observable
objects are cached on Query, Relation, but only for as long as they’re observed. AndCollection
has a cache of{ id : Record }
objects. Once object with given ID is fetched, it’s going to stay there forever.My initial plan was to implement a two-level cache, keeping Records in a Map for the first X (100? 200?) records, and then move oldest records to a WeakMap, so that they’re cached only as long as some piece of the app actually keeps a reference to it. If memory usage is important to your app, try contributing this improvement - it may help a lot if you’re dealing with a lot of Records
No, as long as you clearly convey that the API may change or not fully work, e.g.
Q.experimentalSortBy()
.