469,275 Members | 1,802 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

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 47450
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by SMG - Idealake | last post: by
8 posts views Thread by =?Utf-8?B?UGlnZ3k=?= | last post: by
16 posts views Thread by Lamont Sanford | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.