Is there a way to find how much size a state (object, array, etc) or a component occupies in memory.
In my current context, I need that to know if a specific state/component is very heavy (in term of memory).
In chrome, I already tried to snapshot the memory, but I couldn't find how to identify a specific component or state in the result in such large info like this:
The Vuex library offers the centralized store for managing the state for Vue.js components. It is responsible for getting and updating the state of every value which are declared using the Vuex library. Create modules/user-module.js file and paste the below code in it.
Vuex is a state management pattern + library for Vue.js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion.
Use computed properties, but first, we can map the getters for easy access like so. You have to import { mapGetters } from Vuex to be able to place inside the computed properties. Using the spread operator and pacing each getter as a string array item we can then reference individual getters inside the template.
While the Vue instance has a data property, the Vuex store has state. Both are reactive. And while the instance has methods, which among other things can update data, the store has Actions, which can update the state.
For variables size you can find it using this js function and then use console logs or using google chrome developer tools
For component size check Linus response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With