java - What is the difference between abstract class and interface in terms of their storage in JVM -
this question has answer here:
what difference between abstract class , interface in terms of storage in jvm. more precise jvm store interfaces memory?
warning: mentioned @assylias, mechanics specific oracle hotspot jvm.
before java8
all meta information stored in permgen, both abstract classes , interfaces. meta information includes class specific information (what fields has, parent, etc).
interface can have public static final fields, field meta information stored in permgen.
abstract class can have both static , non-static fields. however, there no difference in terms of meta information, stored in permgen too. on other hand, real object instances stored in heap both static , non-static fields.
see example
public class myclass { public static final calendar calendar = calendar.getinstance(); private date mydate = new date(); } field information calendar , mydate stored in permgen , real object instances stored in heap.
in java8 permgen moved inside heap space, in so-called metaspace, not see java.lang.outofmemoryerror: permgen space anymore. however, conceptual separation between meta information , object allocation memory still present.
also review @alextaylor specification quotation.
Comments
Post a Comment