Example #1
0
 public LargeGC()
 {
     d        = new double [10625]; //85 KB
     m_pSmall = null;
 }
Example #2
0
 public virtual void AttachSmallObjects(SmallGC small)
 {
     m_pSmall = small;
 }
Example #3
0
    public static void Main(string[] p_args)
    {
        long iterations = 200;

        //Large Object Collection
        CreateLargeObjects();
        GC.Collect();
        GC.WaitForPendingFinalizers();

        for (long i = 0; i < iterations; i++)
        {
            CreateLargeObjects();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }

        //Large Object Collection (half array)
        CreateLargeObjectsHalf();
        GC.Collect();
        GC.WaitForPendingFinalizers();
        GC.Collect();

        for (long i = 0; i < iterations; i++)
        {
            CreateLargeObjectsHalf();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }

        //Promote from Gen1 to Gen2
        SmallGC [] sgc;
        sgc = new SmallGC [LOOP];

        for (int j = 0; j < LOOP; j++)
        {
            sgc[j] = new SmallGC(0);
        }

        GC.Collect();

        for (int j = 0; j < LOOP; j++)
        {
            sgc[j] = null;
        }

        GC.Collect();
        GC.WaitForPendingFinalizers();
        GC.Collect();

        for (long i = 0; i < iterations; i++)
        {
            // allocate into gen 0
            sgc = new SmallGC [LOOP];
            for (int j = 0; j < LOOP; j++)
            {
                sgc[j] = new SmallGC(0);
            }

            // promote to gen 1
            while (GC.GetGeneration(sgc[LOOP - 1]) < 1)
            {
                GC.Collect();
            }

            while (GC.GetGeneration(sgc[LOOP - 1]) < 2)
            {
                // promote to gen 2
                GC.Collect();
            }

            for (int j = 0; j < LOOP; j++)
            {
                sgc[j] = null;
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        //Promote from Gen1 to Gen2 (Gen1 ptr updates)
        List node = PopulateList(LOOP);

        GC.Collect();
        GC.WaitForPendingFinalizers();

        if (List.ValidateList(node, LOOP) == 0)
        {
            Console.WriteLine("Pointers after promotion are not valid");
        }

        for (long i = 0; i < iterations; i++)
        {
            // allocate into gen 0
            node = PopulateList(LOOP);

            // promote to gen 1
            while (GC.GetGeneration(node) < 1)
            {
                GC.Collect();
            }

            while (GC.GetGeneration(node) < 2)
            {
                //promote to gen 2
                GC.Collect();
                GC.WaitForPendingFinalizers();

                if (ValidateList(node, LOOP) == 0)
                {
                    Console.WriteLine("Pointers after promotion are not valid");
                }
            }
        }
    }