我有一个方法,它将PDF文本转换为列表.在此过程之后,内存使用量增加太多.例如1000页pdf使用300mb内存,我无法释放它.我已经阅读了一些LOH文章,但没有找到解决方案.
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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
329 次 |
| 最近记录: |