What should I do when I have situations as the one below, where I'd need to clean an object and immediately free its allocated memory?
After creating a List<string>
with 10 million words, process memory goes up to ~150MB.
List<string> list = new();
int length = 10000000;
for (int i = 0; i < length; i++)
{
list.Add("test");
}
Console.ReadLine();
list.Clear();
Console.ReadLine();
Even though the list is cleared, I don't see memory being freed just after that. Could anyone give me some guidance on this, please?