How to get the size of single document in Mongodb?

In the previous call of Object.bsonsize(), Mongodb returned the size of the cursor, rather than the document. Correct way is to use this command: Object.bsonsize(db.test.findOne()) With findOne(), you can define your query for a specific document: Object.bsonsize(db.test.findOne({type:”auto”})) This will return the correct size (in bytes) of the particular document.

C++ object size with virtual methods

This is all implementation defined. I’m using VC10 Beta2. The key to help understanding this stuff (the implementation of virtual functions), you need to know about a secret switch in the Visual Studio compiler, /d1reportSingleClassLayoutXXX. I’ll get to that in a second. The basic rule is the vtable needs to be located at offset 0 … Read more