So I was playing around with the C# Garbage Collection and I noticed a really weird thing.
Random r = new Random(); byte inl = 0; while(true) { inl = (byte)r.Next(0, 255); Console.WriteLine(inl); GC.Collect(0, GCCollectionMode.Forced, false, false); } I had this code in the main loop. Without the GC.Collect function, the program was running with about 10MB of RAM. But with the GC.Collect function, it is running with 6MB of RAM.
And then my question comes, why didn't the GC automatically delete the variable after it has been written to the console?
Console.WriteLine().Randomdoesn't allocate variables, andinlis in the stack.