Skip to content

Instantly share code, notes, and snippets.

@zensh
zensh / memorySizeOfObject.js
Created Feb 18, 2013
calculate memory size of javascript object, it is not a accurate value!
View memorySizeOfObject.js
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':