Answer the question
In order to leave comments, you need to log in
How to clear memory occupied by C# list?
There is a list of strings List (), I add a lot of elements to it. How to free memory from the list when I don't need it? Please write a command, thanks
Answer the question
In order to leave comments, you need to log in
In theory, you should not bother with the garbage collector.
He himself knows when to check if there are unused objects and will clean them up himself.
If you call it often, in particular GC.Collect, it will slow down your application.
And yet, if you have 20 million lines, then it's better to use IEnumerable and work with a limited number of lines - page by page, for example. Then there will be no problems with memory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question