Beispiel #1
0
        static void Main()
        {
            long initialStructMem = GC.GetTotalMemory(true);
            var  structColors     = new ColorStruct[PixelsCount];

            for (int i = 0; i < structColors.Length; i++)
            {
                structColors[i] = new ColorStruct();
            }

            long postStructMem = GC.GetTotalMemory(true);

            Console.WriteLine("{0} instances of struct: {1}KB",
                              PixelsCount, (postStructMem - initialStructMem) / 1000);

            long initialClassMem = GC.GetTotalMemory(true);
            var  classColors     = new ColorClass[PixelsCount];

            for (int i = 0; i < classColors.Length; i++)
            {
                classColors[i] = new ColorClass();
            }

            long postClassMem = GC.GetTotalMemory(true);

            Console.WriteLine("{0} instances of class: {1}KB",
                              PixelsCount, (postClassMem - initialClassMem) / 1000);
        }
        static void Main()
        {
            long structStartMemory = GC.GetTotalMemory(true);
            ColorStruct[] structColors = new ColorStruct[PixelCount];

            for (int i = 0; i < structColors.Length; i++)
            {
                structColors[i] = new ColorStruct();
            }

            long structEndMemory = GC.GetTotalMemory(true);

            Console.WriteLine("{0} instances of struct: {1} KB", PixelCount, (structEndMemory - structStartMemory) / 1000);

            long classStartMemory = GC.GetTotalMemory(true);
            ColorClass[] classColors = new ColorClass[PixelCount];

            for (int i = 0; i < classColors.Length; i++)
            {
                classColors[i] = new ColorClass();
            }

            long classEndMemory = GC.GetTotalMemory(true);

            Console.WriteLine("{0} instances of class: {1} KB", PixelCount, (classEndMemory - classStartMemory) / 1000);
        }
        private static void Main()
        {
            var initialStructMem = GC.GetTotalMemory(true);
            var structColors = new ColorStruct[PixelsCount];
            for (var i = 0; i < structColors.Length; i++)
            {
                structColors[i] = new ColorStruct();
            }

            var postStructMem = GC.GetTotalMemory(true);
            Console.WriteLine("{0} instances of struct: {1}KB", PixelsCount, (postStructMem - initialStructMem) / 1000);

            var initialClassMem = GC.GetTotalMemory(true);
            var classColors = new ColorClass[PixelsCount];
            for (var i = 0; i < classColors.Length; i++)
            {
                classColors[i] = new ColorClass();
            }

            var postClassMem = GC.GetTotalMemory(true);
            Console.WriteLine("{0} instances of class: {1}KB", PixelsCount, (postClassMem - initialClassMem) / 1000);
        }