var sizeof = require ( 'object-sizeof' ) ; interface Div { outer : { width : number ; height : number ; } ; innter : { color : string ; } ; } const divStore = [ ] ; class CreateOuterDiv { width : number = 100 ; height : number = 100 ; } class CreateInnerDiv { public color = this . randomColor ( ) ; private randomColor ( ) { const color = [ 'red' , 'green' , 'blue' , 'white' , 'black' ] ; return color [ Math . floor ( Math . random ( ) * color . length ) ] ; } } const outerDiv = new CreateOuterDiv ( ) ; let innerDiv ; const store = [ ] ; let count = 100 ; while ( count -- ) { innerDiv = new CreateInnerDiv ( ) ; divStore . push ( { outer : outerDiv , innter : innerDiv } ) ; store . push ( Object . assign ( { } , outerDiv , innerDiv ) ) ; } console . log ( 100 * ( sizeof ( innerDiv ) + sizeof ( outerDiv ) ) ) ; console . log ( 100 * sizeof ( innerDiv ) + sizeof ( outerDiv ) ) ; console . log ( sizeof ( divStore ) ) ; console . log ( sizeof ( store ) ) ;