为什么抛出OutOfMemoryException? [英] Why is OutOfMemoryException thrown?

查看:131
本文介绍了为什么抛出OutOfMemoryException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚为什么每周一次或两次,我的C#服务器应用程序

会抛出OutOfMemoryExceptions。机器中有足够的内存。至于

,据我所知,当抛出异常时,只有400兆的1gig总计

正在使用中。


尝试更新List<>时抛出异常。这里有一些

堆栈跟踪:


===

System.OutOfMemoryException:类型''的异常System.OutOfMemoryException''

被抛出。

在System.Collections.Generic.List`1.set_Capacity(Int 32 value)

at System.Collections.Generic.List`1.EnsureCapacity(I nt32 min)

at System.Collections.Generic.List`1.Add(T item)

at Mosaic .Core.StatUtils.ExtractRORs(MiniPerfItem [] perfItems,Int32

startIdx,Int32 endIdx,Boolean useNAOnNonPosBal)

C:\Development\Mosaic\Mosaic- AM\Mosaic.Core.Shared\Code\Utilities\Statistical\S tatUtils.cs:line

38

===


我在异常时在内存中有很多小对象,但是我没有接近耗尽可用内存的b $ b。有什么想法吗?

解决方案

Lamont Sanford< ya ******** @ sanford.sonwrote:


我不知道为什么每周一次或两次,我的C#服务器应用程序

抛出OutOfMemoryExceptions。机器中有足够的内存。至于

,据我所知,当抛出异常时,只有400兆的1gig总计

正在使用中。


尝试更新List<>时抛出异常。这里有一些

堆栈跟踪:


===

System.OutOfMemoryException:类型''的异常System.OutOfMemoryException''

被抛出。

在System.Collections.Generic.List`1.set_Capacity(Int 32 value)

at System.Collections.Generic.List`1.EnsureCapacity(I nt32 min)

at System.Collections.Generic.List`1.Add(T item)

at Mosaic .Core.StatUtils.ExtractRORs(MiniPerfItem [] perfItems,Int32

startIdx,Int32 endIdx,Boolean useNAOnNonPosBal)

C:\Development\Mosaic\Mosaic- AM\Mosaic.Core.Shared\Code\Utilities\Statistical\S tatUtils.cs:line

38

===


我在异常时在内存中有很多小对象,但是我没有接近耗尽可用内存的b $ b。有任何想法吗?



你知道列表在失败点有多大吗?


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http ://www.msmvps.com/jon.skeet

如果回复小组,请不要给我发邮件


OutOfMemoryException实际上意味着资源不足。你打开文件

而不是丢弃它们吗?

http://mrpmorris.blogspot.com/2006/1...maybe-not.html



你知道列表在故障点有多大吗?


>



最多可以达到数万,但肯定永远不会超过
$ 100 ......


I can''t figure out why once or twice per week, my C# server application
throws OutOfMemoryExceptions. There is plenty of memory in the machine. As
far as I can tell, when the exception is thrown, only 400 megs of 1gig total
is in use.

The exception is thrown while trying to update List<>. Here''s a bit of the
stack trace:

===
System.OutOfMemoryException: Exception of type ''System.OutOfMemoryException''
was thrown.
at System.Collections.Generic.List`1.set_Capacity(Int 32 value)
at System.Collections.Generic.List`1.EnsureCapacity(I nt32 min)
at System.Collections.Generic.List`1.Add(T item)
at Mosaic.Core.StatUtils.ExtractRORs(MiniPerfItem[] perfItems, Int32
startIdx, Int32 endIdx, Boolean useNAOnNonPosBal) in
C:\Development\Mosaic\Mosaic-AM\Mosaic.Core.Shared\Code\Utilities\Statistical\S tatUtils.cs:line
38
===

I have a lot of small objects in memory at the time of the exception but I''m
nowhere close to exhausting available RAM. Any ideas?

解决方案

Lamont Sanford <ya********@sanford.sonwrote:

I can''t figure out why once or twice per week, my C# server application
throws OutOfMemoryExceptions. There is plenty of memory in the machine. As
far as I can tell, when the exception is thrown, only 400 megs of 1gig total
is in use.

The exception is thrown while trying to update List<>. Here''s a bit of the
stack trace:

===
System.OutOfMemoryException: Exception of type ''System.OutOfMemoryException''
was thrown.
at System.Collections.Generic.List`1.set_Capacity(Int 32 value)
at System.Collections.Generic.List`1.EnsureCapacity(I nt32 min)
at System.Collections.Generic.List`1.Add(T item)
at Mosaic.Core.StatUtils.ExtractRORs(MiniPerfItem[] perfItems, Int32
startIdx, Int32 endIdx, Boolean useNAOnNonPosBal) in
C:\Development\Mosaic\Mosaic-AM\Mosaic.Core.Shared\Code\Utilities\Statistical\S tatUtils.cs:line
38
===

I have a lot of small objects in memory at the time of the exception but I''m
nowhere close to exhausting available RAM. Any ideas?

Do you have any idea how big the list is at the point of failure?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


OutOfMemoryException really means "out of resources". Are you opening files
and not disposing them or something?

http://mrpmorris.blogspot.com/2006/1...maybe-not.html



Do you have any idea how big the list is at the point of failure?

>

At max it could get up to the tens of thousands, but certainly never over
100k...


这篇关于为什么抛出OutOfMemoryException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆