Beispiel #1
0
        public static int Main(String [] args)
        {
            int iSize = 1000;

            Object [] arVar = new Object[iSize];
            root = new GCHandle[iSize];
            RootMem rm_obj;

            Console.WriteLine("Test should return with ExitCode 100 ...");

            for (n = 0; n < iSize; n++)
            {
                rm_obj  = new RootMem(n);
                root[n] = GCHandle.Alloc(rm_obj);
            }
            //Console.WriteLine("After save objects to Root and before GCed: "+GC.GetTotalMemory(false) );
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            //Console.WriteLine("After save objects to Root and after GCed: "+GC.GetTotalMemory(false) );

            Object v;

            for (int i = 0; i < iSize; i++)
            {
                v = (root[i]);
            }
            //Console.WriteLine("After Get objects from root and before GCed: "+GC.GetTotalMemory(false) );
            GC.Collect();
            //Console.WriteLine("After Get objects from root and after GCed: "+GC.GetTotalMemory(false) );

            for (int i = 0; i < iSize; i++)
            {
                root[i].Free();
            }
            //Console.WriteLine("After free root and before GCed: "+GC.GetTotalMemory(false) );
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            //Console.WriteLine("After free root and after GCed: "+GC.GetTotalMemory(false) );
            try
            {
                for (int i = 0; i < iSize; i++)
                {
                    arVar[i] = (root[i].Target);
                }
            }
            catch (System.InvalidOperationException)
            {
                //expected exception is throw after gchandles were free
                Console.WriteLine("test Passed");
                return(100);
            }

            Console.WriteLine("test failed");
            return(1);
        }
Beispiel #2
0
        public static int Main( String [] args )
        {
            int iSize = 1000;
            Object [] arVar = new Object[iSize];
            root = new GCHandle[iSize];
            RootMem rm_obj;

            Console.WriteLine("Test should return with ExitCode 100 ...");

            for( n=0; n< iSize; n++ )
            {
                 rm_obj = new RootMem( n );
                 root[n] = GCHandle.Alloc(rm_obj );
            }
            //Console.WriteLine("After save objects to Root and before GCed: "+GC.GetTotalMemory(false) );
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            //Console.WriteLine("After save objects to Root and after GCed: "+GC.GetTotalMemory(false) );

            Object v;
            for( int i=0; i< iSize; i++)
            {
                v = ( root[i]) ;
            }
            //Console.WriteLine("After Get objects from root and before GCed: "+GC.GetTotalMemory(false) );
            GC.Collect();
            //Console.WriteLine("After Get objects from root and after GCed: "+GC.GetTotalMemory(false) );

            for( int i=0; i<iSize; i++ )
            {
                root[i].Free();
            }
            //Console.WriteLine("After free root and before GCed: "+GC.GetTotalMemory(false) );
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            //Console.WriteLine("After free root and after GCed: "+GC.GetTotalMemory(false) );
            try
            {
                for( int i=0; i<iSize; i++ )
                {
                    arVar[i]= ( root[i].Target  );
                }
            }
            catch(System.InvalidOperationException)
            {
                //expected exception is throw after gchandles were free
                Console.WriteLine("test Passed");
                return 100;
            }

            Console.WriteLine("test failed");
            return 1;
        }
Beispiel #3
0
 public static int Main(String[] args)
 {
     int iSize = 1000;
     root = new GCHandle[iSize];
     RootMem rm_obj;
     rm_obj = new RootMem(10);
     for (n = 0; n < iSize; n++)
     {
         root[n] = GCHandle.Alloc(rm_obj);
         if (n % 50 == 0)
             Console.Out.WriteLine(n);
     }
     return 100;
 }
Beispiel #4
0
        public static int Main(String[] args)
        {
            int iSize = 1000;

            root = new GCHandle[iSize];
            RootMem rm_obj;

            rm_obj = new RootMem(10);
            for (n = 0; n < iSize; n++)
            {
                root[n] = GCHandle.Alloc(rm_obj);
                if (n % 50 == 0)
                {
                    Console.Out.WriteLine(n);
                }
            }
            return(100);
        }