-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Big data set issue #4384
Comments
Could you please provide a demonstration of this, on jsfiddle for example? How ecactly do you "put an item into a vue instance"? |
Sorry for not being clear enough, here is the fiddle you asked: |
I made some more test and it looks like I made some false statements about memory leak. It looks like if you make an object reactive in a vue instance and put that object in another instance or again in the first instance then the observer property is not added again, nor additional getters and setters are added. Am i right now? |
Yes, https://github.com/vuejs/vue/blob/dev/src/core/observer/index.js#L112
And
are conflicting requirements, IMHO. To observe one object you have to maintain an observer. Maybe Vue can have smaller observer instances, I'm not sure. But currently the workaround might be partition your data. That is, only maintain a set of objects you want to keep reactive and clean the reactive set. Another suggestion is mark immutable properties with |
Are not conflicting anyhow. |
A suitable workaround would be if i could determine unused observers in object (objects which does not have reference in a vue instance or vuex) somehow, so i could delete unused observer properties, and unused getters and setters, freeing up memory from currently unused objects. Then readd observers again as default when the object is used again. |
Might something like this work out for you? http://jsfiddle.net/Linusborg/bLaowkjf/7/ Essentially,:
This is a quick&dirty demo, of course - it can be further improved, e.g. using deep-cloning when you work with nested objects/arrays. |
Thanks for working with the issue, What i was thinking but not sure if it can work, is:
The thing why i wanted to stay away from this is, the fact its go away from the vue's "the one source of truth" data model. |
With your latest comment in mind, my proposal would be to then clone the old item when a new one gets swapped in. The cloned object will not have reactive properties. Then, take that cloned object and assign it back to the array: In this method, you maintain the single source of truth because the picked item is being made reactive in-place when you pick it, and then cloned back to a non-reactive item when you're done with it. |
@sirlancelot |
Will any of these items be mutated? If they are not, you can simply call Even if you do need to mutate them, you can instead do something like |
The items global object is mutated all them time from a network source, and that is the point why I chose Vue cuz the reactive objects mutations updates the view anytime without knowing or listening for object mutations.
With Vue I manager to achieve these goals without any problem expects from the increase of the memory use during using the app. So i can't freeze the object or clone it before i make it reactive cuz i need the original object reference to get reactive view update when the global object is mutated . http://jsfiddle.net/bLaowkjf/9/ |
I will close this for now, as this turned into more of a support thread than a bug report or feature request. Feel free to continue conversation. and open another issue if it leads to an actual issue. |
As I stated before this was an actual feature request. |
Yes please (no guarantees weither this is feasable, though). |
@kailniris jsfiddle: http://jsfiddle.net/otcL62wx/ Therefore, #4437 shouldn't be necessary. |
Thanks for working with the issue! |
@kailniris Any updates? 😄 |
@fnlctrl Sorry for keep You waiting. I am still making some tests and working to implement this pattern on my code. I will respond back asap as I will have some results. |
Sorry, for the late replay. I managed to implement the pattern and made lots of tests. |
Glad to help! |
|
Just had this issue.
Doing it that way caused the UI to update with the post tax value, because somewhere in the HTML we were listening to this.selectedPrice. So, after a couple of hours of research, trial and error, tried this:
This allowed me to make all the operations without activating or modifying the selectedPrice object on data() thus, no unwanted ui updates. 😄 |
Hello,
I have an issue with handling big data set in Vue.js
The app:
The app has like 50k objects in its memory, lets call them items. Every item has an _id and a name property. I want to list the items to the user one at a time. The user picks an item then i put the item in the Vue instance to render it on screen.
The problem:
The data set is like 4 mb big. If i put all the data set (the items object) into a vue instance the 4mb data with the observer properties will be 85 mb. I tried to put the data set into a vuex store, the result was 89mb of memory usage. (This is only a test case, the real production data is like 100mb so in a vuex store it will be instant out of memory i guess).
So I did not put all the data in the instance cuz i do not want reactivity for all the objects, only the one the user picked at that time. So i store the data set in a plain object and if a user pick a an item i put the item into the vue instance then i will have reactivity for that one item. Everything good expects it causes memory leak. Every time i put an item into a vue instance a new observer property will be added to the object. Even if the object was in the instance before a new observer is added next to the unused ones. This works as intended i guess but my issue/feature request is:
Can i somehow remove unused observers and getter/setters or are there any other practices to handle big data set in vue?
Things that would solve the issue but I can't use them:
I could deep clone the item before put it into the vue instance, but i need to keep the original object refence cuz other parts of the app updates the object and i want to keep reactivity.
Could use a database engine but I need to have offline capability and fast IOless memory search locally.
Here are the test cases I made:
The text was updated successfully, but these errors were encountered: