473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Exception of type System.OutOfMemoryException was thrown.

Exception of type System.OutOfMemoryException was thrown.

this error is occuring when on arbitrary threads in my .net windows service.
There is 2 gigs of memory on the machine and this .net windows service only
uses 50 megabytes. What could be causing this? how to fix?
Feb 24 '06 #1
4 47684
Daniel,

I've seen OutOfMemory exceptions thrown when the problem is completely
different. For example Graphics.DrawLine throws this exception and obviously
there is no memory issue. I'd suggest to debug the code and find out what
the real reason for that might be.
"Daniel" <so*******************@yahoo.com> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
Exception of type System.OutOfMemoryException was thrown.

this error is occuring when on arbitrary threads in my .net windows
service.
There is 2 gigs of memory on the machine and this .net windows service
only
uses 50 megabytes. What could be causing this? how to fix?

Feb 24 '06 #2

You can run out of memory if your application is not releasing pinned
memory blocks because the garbage collector only frees memory up to the
first pinned block. Aka if your application pins some memory, then
allocates heap space, then pins more memory, then allocates more heap
space - eventually you will have memory issues because the last pinned
block will "slide" down the heap leaving less and less free space to a
point where an allocation request fails...

You can check your heap usage with perfmon and the .NET memory & GC
performance counters; this will tell you if the out of memory exception
is a red herring or not. If it is a real out of memory condition then
you can use CLRProfiler {free download from msdn website} to see heap
usage in detail...

Also, if it is a real out of memory condition, then in code you might
look for:

- Assure that any class that implements the IDisposable interface is
wrapped in a "using" statement block or else is explicitly disposed in
a finally block

- Assure that pinned {fixed in C#} objects are going out of scope in a
timely manner

- For v1.x of .NET, assure that any COM Interop RCW classes are
explicitly freed with Marshal.ReleaseCOMObject()

Feb 24 '06 #3

"Crash" <so*********@san.rr.com> wrote in message
news:11*********************@t39g2000cwt.googlegro ups.com...
|
| You can run out of memory if your application is not releasing pinned
| memory blocks because the garbage collector only frees memory up to the
| first pinned block. Aka if your application pins some memory, then
| allocates heap space, then pins more memory, then allocates more heap
| space - eventually you will have memory issues because the last pinned
| block will "slide" down the heap leaving less and less free space to a
| point where an allocation request fails...
|

Not true, pinning only prevents compactation of the heaps (managed) that
means that memory consumption grows while large blocks of the heap aren't
used to contain live objects, but the memory consumption grows! which is not
the case here (50MB used).

Willy.
Feb 25 '06 #4

"Daniel" <so*******************@yahoo.com> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
| Exception of type System.OutOfMemoryException was thrown.
|
| this error is occuring when on arbitrary threads in my .net windows
service.
| There is 2 gigs of memory on the machine and this .net windows service
only
| uses 50 megabytes. What could be causing this? how to fix?
|
|

Please be more specific - What memory? How did you measure, what are you
doing in this Service, you aren't using System.Drawing namespace classes do
you?

Willy.
Feb 25 '06 #5

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

Similar topics

1
by: Ripul Handa | last post by:
Hi We are running IIS 5.0 cluster with cisco local director. We are running a website on 2 webservers and I have been observing that from past few days we have are getting this error message of...
1
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...
5
by: karups | last post by:
Hi, There are several pages that occasionally start throwing System.OutOfMemoryException and "The type initializer for...
8
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...
16
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,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.