Display Plugin Settings Storage Sizes
Aug 16, 2013 21:47:27 GMT -8
Todge, ®i©hie, and 8 more like this
Post by Wormopolis on Aug 16, 2013 21:47:27 GMT -8
Plugin settings are capped at 64kb of storage. this includes not only data you have added into the settings, but the settings setups themselves.
place this code in your global header or footer. it will put a little orange plug down in the pbn-tray in the bottom right corner. clicking the image will put up a dialog listing all of the plugins you have running and the storage space they take up. the more important number is the "total settings size". if that is approaching 64k, then you are going to start having issues.
place this code in your global header or footer. it will put a little orange plug down in the pbn-tray in the bottom right corner. clicking the image will put up a dialog listing all of the plugins you have running and the storage space they take up. the more important number is the "total settings size". if that is approaching 64k, then you are going to start having issues.
<script type="text/javascript">
<!--
// plugin settings size check
// roughSizeOfObject function found on http://stackoverflow.com/questions/1248302/javascript-object-size
// by Wormopolis
// v1.01
function roughSizeOfObject( object ) {
var objectList = [];
var stack = [ object ];
var bytes = 0;
while ( stack.length ) {
var value = stack.pop();
if ( typeof value === 'boolean' ) {
bytes += 4;
}
else if ( typeof value === 'string' ) {
bytes += value.length * 2;
}
else if ( typeof value === 'number' ) {
bytes += 8;
}
else if
(
typeof value === 'object'
&& objectList.indexOf( value ) === -1
)
{
objectList.push( value );
for( i in value ) {
stack.push( value[ i ] );
}
}
}
return bytes;
}
function getSettingsSize() {
var ret='';
for(pn in proboards.plugin._plugins) {
var totalSize=JSON.stringify(proboards.plugin._plugins[pn]).length;
var getback=roughSizeOfObject(proboards.plugin._plugins[pn]);
var kconvert1=parseInt((100*totalSize/1024))/100.0, kconvert2=parseInt(100*getback/1024)/100.0;
ret+='<font size="3">name: '+pn+'</font><br><font style="margin-left:15px">total settings size: '+totalSize+' bytes ('+kconvert1+' kb)</font><br><font style="margin-left:15px">data size: '+getback+' bytes ('+kconvert2+' kb)</font><br><br>';
}
proboards.dialog("Plugin_Settings_Sizes", {
html : ret,
title : "Plugin Settings Sizes",
hide: "puff",
show: "fold",
height : 500,
width : 700,
resizable : false,
autoOpen : true
});
}
$(document).ready(function(){
$('div#pbn-bar').css('width','auto').append($('<img src="http://i197./aa250/WORMOPOLIS/02920338-e74f-4011-83a6-7902a779b33f.jpg">').css({'display':'inline-block','margin-right':'2px'}).bind('click',getSettingsSize));
});
</script>