How many bytes does the stack with N elements use?

I would like to analyze the performance of space, and I have the following code:

public class ListStack<T> : IStack<T> { private class Node { public Node next; public T value; } private string[] arr; private Node last; private int size; .... } 

How much space does he use?

I know that in Java this code will have:

16 bytes (service data of the object)

8 bytes (additional overhead for the inner class)

8 bytes (String reference)

8 bytes (link to Node)

8 bytes (array reference)

24 bytes (overhead of the array)

...

But what about C # (including registration, array overhead, etc.)? C # uses the same space as Java? If not, then what's the difference between the two?

+4
source share

All Articles