Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuex profiling : How to know a vuex state or a component size in memory

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:

enter image description here

like image 564
4givN Avatar asked Apr 02 '19 13:04

4givN


People also ask

How to manage the state of Vuex components?

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.

What is the use of Vuex?

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.

How to use computed properties in a Vuex template?

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.

What is the difference between Vue instance and Vuex store?

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.


Video Answer


1 Answers

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.

like image 161
LastM4N Avatar answered Sep 28 '22 00:09

LastM4N