Memory allocation for a class with deep inheritance in .NET.

If I have classes A, B, C, D, Eand interfaces, such as X, Y, Z, and model the system, for example:

class B : A, X
class C : B, Y
class D : C, Z
class E : D

If it Ais an abstract base class, and E is an interest class, when I create an instance of E, will it in turn create instances A, B, C, D, X, Y, Zin addition to E?

If this happens, will this create huge overhead? Not memory, but runtime and GC wise.

+5
source share
3 answers

, "" A, B, C D
, X, Y Z ( )

GC (ABCD), E 1 . .

( E A), , , 1.

+7

- E, , . ( , .) ( , , ), , .

E "" A, B, C, D, X, Y Z , , .

+7

. E, , A, B, C, D E. , X, Y Z.

+2
source

All Articles