I found a similar question to mine:
"Is class member function code memory allocated once or at every instantiation of objects? ", which can be found here
But the answer there only talked about the case for C/C++. Could anyone please tell me the answer to this question if I am using Java?
Is class member function code memory allocated once or at every instantiation of objects
It is allocated once per class, not once per object. To be precise, it is allocated once per class/classloader pair. You can think of it as being allocated by the compiler, as long as you understand the compiler to include whatever the JIT or HotSpot does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With