I'm making a game and I'd like to measure how much memory would be occupied by a concept I'm testing. I recognize it wouldn't be 100% accurate, but does this give me a reliable ballpark figure on the size of the object?
using System;
using System.Collections.Generic;
namespace Sandbox
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long startMemory = GC.GetTotalMemory(true);
            Dictionary<short, KeyValuePair<short, short>> values = new Dictionary<short, KeyValuePair<short, short>>();
            for (short i = 0; i < 3000; i++)
            {
                values.Add(i, new KeyValuePair<short, short>(short.MaxValue, short.MaxValue));
            }
            Console.WriteLine(GC.GetTotalMemory(true) - startMemory);
        }
    }
}
 
    