473,779 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is OutOfMemoryExce ption thrown?

I can't figure out why once or twice per week, my C# server application
throws OutOfMemoryExce ptions. 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.OutOfMem oryException: Exception of type 'System.OutOfMe moryException'
was thrown.
at System.Collecti ons.Generic.Lis t`1.set_Capacit y(Int32 value)
at System.Collecti ons.Generic.Lis t`1.EnsureCapac ity(Int32 min)
at System.Collecti ons.Generic.Lis t`1.Add(T item)
at Mosaic.Core.Sta tUtils.ExtractR ORs(MiniPerfIte m[] perfItems, Int32
startIdx, Int32 endIdx, Boolean useNAOnNonPosBa l) in
C:\Development\ Mosaic\Mosaic-AM\Mosaic.Core. Shared\Code\Uti lities\Statisti cal\StatUtils.c s: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?

Oct 11 '07 #1
16 22243
Lamont Sanford <ya********@san ford.sonwrote:
I can't figure out why once or twice per week, my C# server application
throws OutOfMemoryExce ptions. 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.OutOfMem oryException: Exception of type 'System.OutOfMe moryException'
was thrown.
at System.Collecti ons.Generic.Lis t`1.set_Capacit y(Int32 value)
at System.Collecti ons.Generic.Lis t`1.EnsureCapac ity(Int32 min)
at System.Collecti ons.Generic.Lis t`1.Add(T item)
at Mosaic.Core.Sta tUtils.ExtractR ORs(MiniPerfIte m[] perfItems, Int32
startIdx, Int32 endIdx, Boolean useNAOnNonPosBa l) in
C:\Development\ Mosaic\Mosaic-AM\Mosaic.Core. Shared\Code\Uti lities\Statisti cal\StatUtils.c s: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.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 11 '07 #2
OutOfMemoryExce ption really means "out of resources". Are you opening files
and not disposing them or something?

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


Oct 11 '07 #3
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...
Oct 11 '07 #4
OutOfMemoryExce ption really means "out of resources". Are you opening
files and not disposing them or something?

http://mrpmorris.blogspot.com/2006/1...maybe-not.html
Interesting. I'll check out the article.

No, I don't make use of files to any major extent, but I do use a lot of
database connections. Maybe I'm not closing them properly?
Oct 11 '07 #5
Most likely - improperly closed / disposed connection objects means you run
out of Connection Pool connections, which can cause exceptions similar to
what you're seeing - especially if combined with other code.

1) use the same connection string througout your app.
2) open a connection just before you need to do database call.
3) close the connection immediately after - this returns it to the pool
4) be very careful with DataReaders as they hold open a connection.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Lamont Sanford" wrote:
OutOfMemoryExce ption really means "out of resources". Are you opening
files and not disposing them or something?

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

Interesting. I'll check out the article.

No, I don't make use of files to any major extent, but I do use a lot of
database connections. Maybe I'm not closing them properly?
Oct 11 '07 #6
Lamont Sanford <ya********@san ford.sonwrote:
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...
That sounds unlikely to be the issue then.

Can I suggest that you use perfmon to look at both the heap and the
handle count of your process?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 11 '07 #7
Lamont Sanford pisze:
I can't figure out why once or twice per week, my C# server application
throws OutOfMemoryExce ptions. 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.OutOfMem oryException: Exception of type 'System.OutOfMe moryException'
was thrown.
at System.Collecti ons.Generic.Lis t`1.set_Capacit y(Int32 value)
at System.Collecti ons.Generic.Lis t`1.EnsureCapac ity(Int32 min)
at System.Collecti ons.Generic.Lis t`1.Add(T item)
at Mosaic.Core.Sta tUtils.ExtractR ORs(MiniPerfIte m[] perfItems, Int32
startIdx, Int32 endIdx, Boolean useNAOnNonPosBa l) in
C:\Development\ Mosaic\Mosaic-AM\Mosaic.Core. Shared\Code\Uti lities\Statisti cal\StatUtils.c s: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?
Maybe due to extensively allocating and freeing memory, your memory is
too much fragmentized ?

Regards
Oct 11 '07 #8
>
That sounds unlikely to be the issue then.

Can I suggest that you use perfmon to look at both the heap and the
handle count of your process?
Sure, I'll check it out. I've never used permon before. What signs/symptoms
should I be looking for?
Oct 12 '07 #9
Maybe due to extensively allocating and freeing memory, your memory is
too much fragmentized ?
How would I go about defragmenting it? Should I manually run a garbage
collection?
Oct 12 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4994
by: SMG - Idealake | last post by:
Hi all, I am getting following error on my error, what could be the reason? Exception of type System.OutOfMemoryException was thrown. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.
8
12573
by: =?Utf-8?B?UGlnZ3k=?= | last post by:
Hi to all, I am getting this System.OutOfMemoryException calling the Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(<stream>,<Obj>) method. The type of <streamis IO.MemoryStream =====Exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
19
2049
by: Lamont Sanford | last post by:
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'
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.