![]() |
![]() |
![]() |
Replicating code on object allocation? When you create or allocate a new object is only the data allocated or is a new set of code also allocated? I wouldn't think that it would be, I would think that there is a one to many relationship between the data and the code. One set of code in the code segment serves many different allocations of data on the heap. Not sure what advantage replicating code would be upon object creation, maybe in a server environment it would make sense for multiple simultaneous processes. Thought I'd throw this out to see if anyone can explain it.
Red Oak
Only the data is allocated. If you have a structure that's 8 bytes long and you make it an object, it'll still be 8 bytes long.
Alyosha`
Unless you have any virtual functions, in which case there is an extra 4 bytes for each instance of the object.
Alex.ro
and then you get into tear-offs
mb
Um, in any particular language? I realize they are likely similar, but you can't really answer the question without knowing....
sgf
|