public bool RunTest() { obj = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Console.Write(BNode.icFinalNode); Console.WriteLine(" Nodes were finalized and resurrected."); for (int i = 0; i < BNode.rlNodeCount; i++) { BNode oldNode = (BNode)BNode.rlNode[i]; if ( oldNode.mem[0] != 99 ) { Console.WriteLine( "One Node is not resurrected correctly."); } oldNode = null; BNode.rlNode[ i ] = null; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); return ( BNode.icCreateNode == BNode.icFinalNode ); }
public void DeleteObj(int iObj,int iSwitch) { for( int i= 0; i< iObj; i++ ) { rgNode[i] = new BNode( i+1 ); alWeakRef.Add( new WeakReference( rgNode[i], (iSwitch == 1) ) ); } GC.Collect(); for( int i=0; i< iObj; i++) { if ( (alWeakRef[ i ]).Target == null ) { //*all weakref have strong reference, so it should not return null bret = false; } } for( int i=0; i< iObj; i++) { rgNode[i] = null; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }
#pragma warning restore 0414 public CreateObj() { Continue mv_Obj = new Continue(); for( int i=1; i< 1000; i++) { obj = new BNode(i); //create new one and delete the last one. mv_Obj.CreateNode( i ); //create locate objects in createNode(). } Console.Write(BNode.icCreateNode); Console.WriteLine(" Nodes were created."); }
public void CreateNode( int i ) { BNode rgobj = new BNode( i ); }
public void CreateNode(int i) { BNode rgobj = new BNode(i); }
public void DestroyNode() { obj = null; }
#pragma warning restore 0414 public CreateObj() { mv_Obj = new BaseFinal(); //Printing GetTotalMemory is commented out so that the test can build on RedHawk //Console.WriteLine("before test started, the heapsize is {0}", GC.GetTotalMemory(false)); for( int i=1; i< 1000; i++) { obj = new BNode(i); //create new one and delete the last one. mv_Obj.CreateNode( i ); //create locate objects in createNode(). } Console.Write(BNode.icCreateNode); Console.WriteLine(" Nodes were created."); //Console.WriteLine("after all objects were created, the heapsize is " + GC.GetTotalMemory(false)); }
public bool RunTest() { obj = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Console.Write(BNode.icFinalNode); Console.WriteLine(" Nodes were finalized and resurrected."); //Console.WriteLine("after all objects were deleted and resurrected in Finalize() , the heapsize is " + GC.GetTotalMemory(false)); for(int i=0; i< BNode.rlNode.Count; i++) { BNode oldNode = (BNode)BNode.rlNode[ i ]; if ( oldNode.mem[0] != 99 ) { Console.WriteLine( "One Node is not resurrected correctly."); } oldNode = null; BNode.rlNode[ i ] = null; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); //Console.WriteLine("after all objects were deleted , the heapsize is " + GC.GetTotalMemory(false)); return ( BNode.icCreateNode == BNode.icFinalNode ); }
public void DestroyObj() { obj = null; }