How to get the size of a JavaScript object?

I want to know the size occupied by a JavaScript object. Take the following function: function Marks(){ this.maxMarks = 100; } function Student(){ this.firstName = “firstName”; this.lastName = “lastName”; this.marks = new Marks(); } Now I instantiate the student: var stud = new Student(); so that I can do stuff like stud.firstName = “new Firstname”; … Read more

Why isn’t sizeof for a struct equal to the sum of sizeof of each member?

Why does the sizeof operator return a size larger for a structure than the total sizes of the structure’s members? 12 s 12 This is because of padding added to satisfy alignment constraints. Data structure alignment impacts both performance and correctness of programs: Mis-aligned access might be a hard error (often SIGBUS). Mis-aligned access might … Read more