A
Ashish Sheth
Hi gurus,
I have this question from last so many years and I tried to find out but
couldn't find anything.
Basically suppose one class is having two integer member variables and one
method. My question is How much memory will be consumed by each instance of
the class? OK I know that since there are two integer member variable it
will consume 2* 4 bytes but what about the Method code? will the method code
will be shared by the two different instance or the method code be copied
for the all the instances? If it is not copied(i.e. shared) then How the
method will be encapsulated so that only instance of that class only can
call the method? the final question is Does the memory allocated by the
object comprises the memory taken by the method code(or method pointer or
whatever) ?
thanks and regards,
Ashish Sheth.
I have this question from last so many years and I tried to find out but
couldn't find anything.
Basically suppose one class is having two integer member variables and one
method. My question is How much memory will be consumed by each instance of
the class? OK I know that since there are two integer member variable it
will consume 2* 4 bytes but what about the Method code? will the method code
will be shared by the two different instance or the method code be copied
for the all the instances? If it is not copied(i.e. shared) then How the
method will be encapsulated so that only instance of that class only can
call the method? the final question is Does the memory allocated by the
object comprises the memory taken by the method code(or method pointer or
whatever) ?
thanks and regards,
Ashish Sheth.