Monday, March 9, 2009

Virtual methods in C++ cause more RAM consumption WHY??

http://www.alexandersandler.net/how-inheritance-encapsulation-and-polymorphism-work-in-cpp

The reason is when you use virtual method in class then compiler puts a "virtualmethodtable" at the beginning of each instance of class. This leads to increase in size for each instance by 4-8 bytes and hence overall size increases largely.

No comments:

Post a Comment