Esempio n. 1
0
        public void SetThread()
        {
            itype = 4;
            AddObjectToRecord();
            LeakWheel mv_obj = new LeakWheel();

            mv_obj.ThreadNode();
        }
Esempio n. 2
0
        public void ThreadNode()
        {
            Dictionary <int, WeakReference> oTable = new Dictionary <int, WeakReference>(10);
            Node      LstNode = null; //the last node in the node chain//
            Random    r       = new Random(LeakWheel.iSeed);
            LeakWheel mv_obj  = new LeakWheel();

            while (true)
            {
                LstNode = mv_obj.SpinWheel(oTable, LstNode, r);

                if (GC.GetTotalMemory(false) >= LeakWheel.iMem * 60)
                {
                    LstNode = null;

                    GC.Collect( );
                    GC.WaitForPendingFinalizers();
                    GC.Collect( );
                    Console.WriteLine("After Delete and GCed all Objects: {0}", GC.GetTotalMemory(false));
                }
            }
        }
Esempio n. 3
0
 public void SetThread()
 {
     itype = 4;
     AddObjectToRecord();
     LeakWheel mv_obj = new LeakWheel();
     mv_obj.ThreadNode();
 }
Esempio n. 4
0
        public void ThreadNode()
        {
            Dictionary<int, WeakReference> oTable = new Dictionary<int, WeakReference>( 10);
            DestroyLstNode(); //the last node in the node chain//
            Random  r = new Random (LeakWheel.iSeed);
            LeakWheel mv_obj = new LeakWheel();

            while (true)
            {
                mv_obj.SpinWheel( oTable, LstNode, r );

                if( GC.GetTotalMemory(false) >= LeakWheel.iMem*60 )
                {
                    DestroyLstNode();

                    GC.Collect( );
                    GC.WaitForPendingFinalizers();
                    GC.Collect( );
                    Console.WriteLine( "After Delete and GCed all Objects: {0}", GC.GetTotalMemory(false) );
                }
            }
        }
Esempio n. 5
0
        public static int Main( String [] Args)
        {
            // console synchronization Console.SetOut(TextWriter.Synchronized(Console.Out));

            /*max memory will be used. If heap size is bigger than this, */

            // delete all the objects. Default 10MB
            iMem = 10;

            //How many iterations
            iIter = 1500000;

            //Max items number in the object table
            iTable = 500;

            //Seed for generate random iKey
            iSeed = (int)DateTime.Now.Ticks; 

            switch( Args.Length )
            {
                case 1:
                    try{
                        iMem = Int32.Parse( Args[0] );
                    }
                    catch(FormatException)
                    {
                        Console.WriteLine("FormatException is caught");
                    }
                break;
                case 2:
                    try{
                        iMem = Int32.Parse( Args[0] );
                        iIter = Int32.Parse( Args[1] );
                    }
                    catch(FormatException )
                    {
                        Console.WriteLine("FormatException is caught");
                    }
                break;
                case 3:
                    try{
                        iMem = Int32.Parse( Args[0] );
                        iIter = Int32.Parse( Args[1] );
                        iTable = Int32.Parse( Args[2] );
                    }
                    catch(FormatException )
                    {
                        Console.WriteLine("FormatException is caught");
                    }
                 break;
                case 4:
                    try
                    {
                        iMem = Int32.Parse(Args[0]);
                        iIter = Int32.Parse(Args[1]);
                        iTable = Int32.Parse(Args[2]);
                        iSeed = Int32.Parse(Args[3]);
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("FormatException is caught");
                    }
                break;
            }

            Console.WriteLine("Repro with these values:");
            Console.WriteLine("iMem= {0} MB, iIter= {1}, iTable={2} iSeed={3}", iMem, iIter, iTable, iSeed );

            LeakWheel mv_obj = new LeakWheel();
            

            if(mv_obj.RunGame())
            {
                Console.WriteLine("Test Passed!");
                return 100;
            }

            Console.WriteLine("Test Failed!");
            return 1;

        }
Esempio n. 6
0
        public static int Main(String [] Args)
        {
            // console synchronization Console.SetOut(TextWriter.Synchronized(Console.Out));

            /*max memory will be used. If heap size is bigger than this, */

            // delete all the objects. Default 10MB
            iMem = 10;

            //How many iterations
            iIter = 1500000;

            //Max items number in the object table
            iTable = 500;

            //Seed for generate random iKey
            iSeed = (int)DateTime.Now.Ticks;

            switch (Args.Length)
            {
            case 1:
                try{
                    iMem = Int32.Parse(Args[0]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException is caught");
                }
                break;

            case 2:
                try{
                    iMem  = Int32.Parse(Args[0]);
                    iIter = Int32.Parse(Args[1]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException is caught");
                }
                break;

            case 3:
                try{
                    iMem   = Int32.Parse(Args[0]);
                    iIter  = Int32.Parse(Args[1]);
                    iTable = Int32.Parse(Args[2]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException is caught");
                }
                break;

            case 4:
                try
                {
                    iMem   = Int32.Parse(Args[0]);
                    iIter  = Int32.Parse(Args[1]);
                    iTable = Int32.Parse(Args[2]);
                    iSeed  = Int32.Parse(Args[3]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException is caught");
                }
                break;
            }

            Console.WriteLine("Repro with these values:");
            Console.WriteLine("iMem= {0} MB, iIter= {1}, iTable={2} iSeed={3}", iMem, iIter, iTable, iSeed);

            LeakWheel my_obj = new LeakWheel();

            while (!my_obj.RunGame())
            {
                GC.Collect(2);
                GC.WaitForPendingFinalizers();
                GC.Collect(2);

                Console.WriteLine("After Delete and GCed all Objects: {0}", GC.GetTotalMemory(false));
            }

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

            Thread.Sleep(100);
            GC.Collect(2);
            GC.WaitForPendingFinalizers();
            GC.Collect(2);
            GC.WaitForPendingFinalizers();
            GC.Collect(2);
            GC.WaitForPendingFinalizers();

            Console.WriteLine("When test finished: {0}", GC.GetTotalMemory(false));
            Console.WriteLine("Created VarAry objects: {0} Finalized VarAry Objects: {1}", Node.iVarAryCreat, Node.iVarAryFinal);
            Console.WriteLine("Created BitArray objects: {0} Finalized BitArray Objects: {1}", Node.iBitAryCreat, Node.iBitAryFinal);
            Console.WriteLine("Created small objects: {0} Finalized small Objects: {1}", Node.iSmallCreat, Node.iSmallFinal);
            Console.WriteLine("Created BinaryTree objects: {0} Finalized BinaryTree Objects: {1}", Node.iBiTreeCreat, Node.iBiTreeFinal);
            Console.WriteLine("Created Thread objects: {0} Finalized Thread Objects: {1}", Node.iThrdCreat, Node.iThrdFinal);


            if (Node.iBitAryCreat == Node.iBitAryFinal &&
                Node.iBiTreeCreat == Node.iBiTreeFinal &&
                Node.iSmallCreat == Node.iSmallFinal &&
                Node.iThrdCreat == Node.iThrdFinal &&
                Node.iVarAryCreat == Node.iVarAryFinal)
            {
                Console.WriteLine("Test Passed!");
                return(100);
            }

            Console.WriteLine("Test Failed!");
            return(1);
        }
Esempio n. 7
0
        public static int Main(String [] Args)
        {
            // console synchronization Console.SetOut(TextWriter.Synchronized(Console.Out));

            /*max memory will be used. If heap size is bigger than this, */

            // delete all the objects. Default 10MB
            iMem = 10;

            //How many iterations
            iIter = 1500000;

            //Max items number in the object table
            iTable = 500;

            //Seed for generate random iKey
            iSeed = (int)DateTime.Now.Ticks;

            switch (Args.Length)
            {
            case 1:
                try{
                    iMem = Int32.Parse(Args[0]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException is caught");
                }
                break;

            case 2:
                try{
                    iMem  = Int32.Parse(Args[0]);
                    iIter = Int32.Parse(Args[1]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException is caught");
                }
                break;

            case 3:
                try{
                    iMem   = Int32.Parse(Args[0]);
                    iIter  = Int32.Parse(Args[1]);
                    iTable = Int32.Parse(Args[2]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException is caught");
                }
                break;

            case 4:
                try
                {
                    iMem   = Int32.Parse(Args[0]);
                    iIter  = Int32.Parse(Args[1]);
                    iTable = Int32.Parse(Args[2]);
                    iSeed  = Int32.Parse(Args[3]);
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException is caught");
                }
                break;
            }

            Console.WriteLine("Repro with these values:");
            Console.WriteLine("iMem= {0} MB, iIter= {1}, iTable={2} iSeed={3}", iMem, iIter, iTable, iSeed);

            LeakWheel mv_obj = new LeakWheel();


            if (mv_obj.RunGame())
            {
                Console.WriteLine("Test Passed!");
                return(100);
            }

            Console.WriteLine("Test Failed!");
            return(1);
        }