One of the most exciting challenges in the implementation of object oriented programming languages is to efficiently realize together multiple inheritance and dynamic dispatch. Indeed, it was believed that it was impossible to efficiently introduce multiple inheritance into C++, until proved otherwise by Stroustrup. Although there is a large body of research on the time overhead of object oriented programs, there is little work on memory overhead. To support efficient implementation of dynamic dispatch and multiple inheritance, there are compiler-generated fields, stored in object's memory. This work takes an empirical approach to the study of the memory overhead due to compiler generated fields, which turns out to be significant in the presence of multiple inheritance.We study the performance, in terms of overhead to object size of three compilation strategies: separate compilation, whole program analysis, and user annotations as done in C++. A variant to each such strategy is the inclusion of pointers to indirect virtual bases in objects. Using a database of several large multiple inheritance hierarchies, spanning 7000 classes, several application domains and different programming languages we find that in all strategies there are certain classes which give rise a large number of compiler generated fields in their object layout.
Several recently introduced optimization techniques are studied in this work. Our study shows that the existence of virtual inheritance greatly increases the number of compiler generated fields stored in object memory. Some of the techniques, such as devirtualization and inlining, strive to reduce the number of virtual inheritance in class hierarchies. Others, such as bidirectional layout and packing, minimize the number of compiler generated fields by suggesting major architecture changes. The optimization techniques also broken down by their applicability in different compilation strategies: some require whole program information while others don't. We study the efficacy of the optimization techniques and show that an average saving of close to 50% in object memory overhead can be achieved.