Java memory usage in inheritance

后端 未结 2 1529
花落未央
花落未央 2020-12-17 22:18

What does the memory usage look like in Java when extending a base class.

Do the child class contain an instance of the base class (with it\'s own overhead and all)

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 23:08

    There is only one class header per object, so it has only the latter.

    By the way, you can easily check this using https://sourceforge.net/projects/sizeof/ or https://code.google.com/p/memory-measurer/

提交回复
热议问题