What happens in memory when a C++ class is instantiated -
i'm interested in nuts , boltw of c++ , wondered changes when object instantiated. i'm particularly interested if functions added memory, if there runtime or if never stored in memory @ all.
if direct me site on of core bolts of c , c++, i'd love too.
thanks, jo
a common case is:
- memory allocated calling
operator new
. function in memory, it's needed lot. - the constructor of class called. code in memory. if not, call function page-faults. os notes, , loads appropriate page executable ram. tells os retry. ( 2a. ctor arranges virtual functions callable - writing vtable pointer )
- chances page constructor contains other members of class. can called too. if on page, calling them may cause page fault , load. if compiler put vtable on different page, use of vtable may cause page fault.
the advantage of such load-on-demand mechanism os can avoid loading code class cprinter
if user never intends print document.
Comments
Post a Comment