I have an method and it converts pdf text into a list. After the process the memory usage increase too much. For example a 1000 page pdf use 300mb memory and i can't free it. I have readed some LOH articles but have not find a solution.
public List<string> GetTextFromPdf()
{
if (_pdfDoc.Pages == null) return null;
List<string> ocrList = new List<string>();
foreach (var words in _pdfDoc.Pages.Select(s => s.Value.WordList))
{
ocrList.AddRange(words.Select(word => word.Word).Select(input => Regex.Replace(input, @"[\W]", "")));
}
GC.Collect();
return ocrList;
}