Class Storage – Where Is the Class Itself Stored at Runtime?

cclassjavamemoryobject

In C# or Java we find that the objects are stored on heap and their reference vars are stored on stack. But at run time where is the class definition stored to be used as a template for creating objects?

Best Answer

Class definitions are stored in a separate area (neither stack nor heap) called the method area. In .net the corresponding area is called the Loader Heap. Data in the method area is written by the class loader, and it is never garbage collected and cannot be deleted.