c# - GC.GetGeneration method gives unexpected results -
i have sample code jeffrey richter's book, shown below.
object o = new object(); console.writeline("gen " + gc.getgeneration(o)); // 0. gc.collect(); console.writeline("gen " + gc.getgeneration(o)); // 1. gc.collect(); console.writeline("gen " + gc.getgeneration(o)); // 2 (expected) 0 gc.collect(); console.writeline("gen " + gc.getgeneration(o)); // 2 (expected) 1
can explain why 3rd , 4th calls getgeneration showed 0 , 1 generations instead of 2?
i found out answer. current .net framework of console app 3.5. when changed 4 client profile achieved expected results. have question - differences in garbage collection in .net 3.5 , 4.0 / 4.5?
Comments
Post a Comment