So I'm working with a console app that will persist for days, weeks, or months at a time.
It logs useful information to a text file, but it also writes to the Console. Do I have to worry about the console memory not getting purged for some reason. It seems to be okay.
I wrote a little test to run over lunch. I added some randomly spaced letters so that my coworkers think I must be processing something large and can take a longer lunch.
for (Int64 i = 0; i < 1000000000000000000; i++)
{
string random = Path.GetRandomFileName();
random = random.Replace(".", "");
random = random.Replace("m", " ");
random = random.Replace("a", " ");
random = random.Replace("h", " ");
Console.WriteLine("i " + i + " " + random);
}
So, memory looks stable without writing to a file. I just want some confirmation that if I do have a memory issue, it's not from the console...
Memory does climb ever so slightly if I log it to a text file as well.
It logs useful information to a text file, but it also writes to the Console. Do I have to worry about the console memory not getting purged for some reason. It seems to be okay.
Not unless you have your console set up to have an enormous buffer, or it's redirected to an in-memory file system, or something like that. In normal situations, it should be fine.
Not an issue, any text that scrolls off the console buffer as specified by Console.SetBufferSize() falls in the bit-bucket. The maximum buffer size is 64KB, a restriction that the Console class forgets to check btw.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With