简体   繁体   English

StringBuilder .ToString()抛出OutOfMemory异常

[英]StringBuilder .ToString() throws OutOfMemory Exception

list is a string builder that includes a csv that I'm requesting from a website, toString() is crashing. list是一个字符串构建器,其中包含我从网站请求的csv, toString()正在崩溃。

Exception of type 'System.OutOfMemoryException' was thrown. 

It's worth mentioning that my Microsoft.VsHub.Server.HttpHostx64 is using 5GB of memory, which wasn't the case before. 值得一提的是,我的Microsoft.VsHub.Server.HttpHostx64使用的是5GB的内存,而以前并非如此。

I tried the following: 我尝试了以下方法:

  • Check if I have WebCompanion to uninstall [I didn't] 检查我是否有WebCompanion卸载[我没有]
  • Tried to turn off BrowserLink in VS 试图在VS中关闭BrowserLink
  • Restarted my machine 重启我的机器

I have 3GB of free memory which should be enough to convert a 100MB string. 我有3GB的可用内存,足以转换100MB的字符串。

在此输入图像描述

The reason is the virtual limit on StringBuilder. 原因是StringBuilder的虚拟限制。 if you're not using stream, then do a partial read, read strings up to a certain size, then write them into your text, then empty the builder and repeat. 如果您不使用流,则进行部分读取,读取一定大小的字符串,然后将其写入文本,然后清空构建器并重复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM