Viewing data stored by dcc.Store with type memory

When using dcc.Store in a Dash app with storage types 'session' or 'local', it’s possible to see the contents of the data in your browsers sessionStorage or localStorage. (In Chrome, press F12, Go to the Application tab, in the left menu under Storage, select your tool’s website under Local Storage or Session Storage).

You can even review the size of the storage using this JavaScript code in your website console:

var _lsTotal = 0, _xLen, _x;
for(_x in sessionStorage){
	if(!sessionStorage.hasOwnProperty(_x)){
		continue;
	} 
	_xLen = ((sessionStorage[_x].length + _x.length)* 2);
	_lsTotal += _xLen; 
	console.log(_x.substr(0,50) + " = " + (_xLen/1024).toFixed(2) + " KB")
};
console.log("Total = " + (_lsTotal / 1024).toFixed(2) + " KB");

Is there any way to review the data that is held when selecting storage type 'memory' in dcc.Store? Also, is there any limit to how much you can store in memory? Will the browser allow you to fill up the complete available memory on the users pc?

Hello @Tobs,

From the client, I havent seen any way to know what is in the memory storage dcc.Store. Browsers will cap out the memory based upon different criteria.

With that being said, you can use the memory store in clientside callbacks.

Thanks for the reply and the interesting read. I already guessed it would not be easy. At least it’s useful to know that the memory can be used for storing larger datasets that don’t fit in the session or local storage, but do need to be stored clientside.

1 Like