supposing the following scenario:
void thisIsCalledManyTimes(){
// ....
someObject.executeIfNecessary( new Runnable(){
void run(){ //do sth here}
});
}
how much space would the anonymous object take? I understand that each object anonymous obj would have a pointer to the same implementation of run
in its method lookup table.
The source code of Runnable doesn't specify any fields, and so the anonymous class won't take any more space than an Object
, with two differences. An inner class has an implicit reference to the outer class instance, so you would want to factor this in. It will also take copies of final
variables referenced from the outer class.
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