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.
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.