异常没有被捕获
我有一个非常简单的应用程序,我们向它提供我们的网站列表,它对它们执行并行 foreach,并在每个操作内执行一个 http post 。
类似于下面:
static int success = 0
static void Main(string[] args) {
try {
Parallel.ForEach(sites, site=> {
try{
if(DoWebPost(site)) {
Console.Write("Posted {0} - {1}", ++success, site);
}
} catch {}
});
} catch {}
}
我不明白为什么它会抛出 OutOfMemoryException,更不用说为什么这会导致整个应用程序崩溃,而不仅仅是捕获并继续。
编辑:不完全确定异常发生在哪里,因为它不是在本地发生的,只有在生产中运行时...这意味着无法进行调试。应用程序是 64 位的,很少使用超过 100 兆的内存。
I have a very simple application, we feed it a list of our websites, and it does a parallel foreach on them and inside each action it does an http post to it.
Similar to below:
static int success = 0
static void Main(string[] args) {
try {
Parallel.ForEach(sites, site=> {
try{
if(DoWebPost(site)) {
Console.Write("Posted {0} - {1}", ++success, site);
}
} catch {}
});
} catch {}
}
I can't figure out why it will throw an OutOfMemoryException, let alone why that will cause the entire application to crash, and not just catch and continue.
EDIT: Not exactly sure where the exception occurs, since it doesn't locally, only when running in production... meaning no debugging available. The Application is 64bits, and rarely uses more than 100 megs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 马克·格拉维尔的话
In the words of Marc Gravell
您提到发布的代码与您使用的代码有些相同。
您实际上可以发布完整的代码或导致此问题的确切代码吗?
有消息告诉我你有某种内存泄漏,你需要先解决这个问题。
You mentioned the code that is posted is somewhat the same as the code you used.
Can you actually post the full code or the exact code that is causing this.
Something tells me you have some sort of memory leak, you need to address this first.