4

I would like to analyze space performance 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 it use?

I know that in Java this code will have:

16 bytes (object overhead)

8 bytes (inner class extra overhead)

8 bytes (reference to String)

8 bytes (reference to Node)

8 bytes (reference to array)

24 bytes(array overhead)

...

But what about C# (including padding, array overhead, etc.)? C# use the same amount of space like Java? If not, what the difference between them?

Anatoly
  • 1,908
  • 4
  • 25
  • 47

0 Answers0