Out of memory exception not being thrown

E

Ethan Strauss

Hi,
I am not sure this is the correct newsgroup. If there is a better one,
pleasde let me know.


I have written some memory intensive code in C# using .Net 2.0. I know that
a method I have written can suck up all the memory available to it and cause
an out-of-memory exception, so the calling code catches out of memory
exceptions and deals with them.

My problem is that this does not work on all the machines that need to run
the code. I have a development machine, a staging server, and a production
server. It works fine on my development machine & the staging machine, but
not the production server (of course). On the production server it eats up
all the memroy available to the application pool and then Windows recycles
the application pool because it is out of memory. The Out Of Memory Exception
seems like it is not being generated in the code.

Some machine details.

My development machine
is running Windows XP SP2
has 2 GB RAM
runs at 2.39 GHz
is running IIS
The web application is running on framework 2.0.50727
catches the out of memory error correctly

The staging server
is running Windows Server 2003 SP2
has 756 MB RAM
runs at 2.33 GHz
is running IIS
The web application is running on framework 2.0.50727
catches the out of memory error correctly

The production server
is running Windows Server 2003 SP2
has 756 MB RAM
runs at 1.87 GHz
is running IIS
The web application is running on framework 2.0.50727
DOES NOT catch the out of memory error correctly

The only difference I can see between the two servers is the speed. I don't
see how that could matter for this, but I don't know.

Any other ideas?

Thanks!
Ethan

Ethan Strauss Ph.D.
Bioinformatics Scientist
Promega Corporation
2800 Woods Hollow Rd.
Madison, WI 53711
608-274-4330
800-356-9526
(e-mail address removed)
 
E

Ethan Strauss

Thanks Pete.
I was actually kind of surprised that I could actually catch the exception
when I first did. I thought that if it was out of memory, how can I tell it
what to do??
Unfortunately, I don't think I can improve my algorithm much. It is a well
known bioinformatics algorithm (Smith Waterman sequence alignment
http://en.wikipedia.org/wiki/Smith-Waterman) and I suspect it is about as
good as it gets for what I am trying to do. I would be happy to just be able
to notify the user when they have asked too much of the server.
I certainly see your point about trying to deal with a memory error. I
just found MemoryFailPoint in MSDS documentation. That looks like it might do
what I want. Any thoughts?
Thanks!
Ethan
 
G

Göran Andersson

Ethan said:
Hi,
I am not sure this is the correct newsgroup. If there is a better one,
pleasde let me know.


I have written some memory intensive code in C# using .Net 2.0. I know that
a method I have written can suck up all the memory available to it and cause
an out-of-memory exception, so the calling code catches out of memory
exceptions and deals with them.

My problem is that this does not work on all the machines that need to run
the code. I have a development machine, a staging server, and a production
server. It works fine on my development machine & the staging machine, but
not the production server (of course). On the production server it eats up
all the memroy available to the application pool and then Windows recycles
the application pool because it is out of memory. The Out Of Memory Exception
seems like it is not being generated in the code.

Some machine details.

My development machine
is running Windows XP SP2
has 2 GB RAM
runs at 2.39 GHz
is running IIS
The web application is running on framework 2.0.50727
catches the out of memory error correctly

The staging server
is running Windows Server 2003 SP2
has 756 MB RAM
runs at 2.33 GHz
is running IIS
The web application is running on framework 2.0.50727
catches the out of memory error correctly

The production server
is running Windows Server 2003 SP2
has 756 MB RAM
runs at 1.87 GHz
is running IIS
The web application is running on framework 2.0.50727
DOES NOT catch the out of memory error correctly

The only difference I can see between the two servers is the speed. I don't
see how that could matter for this, but I don't know.

Any other ideas?

Thanks!
Ethan

Is the server running a 32-bit or 64-bit version of Windows?

A 32-bit application can not use more than 4 GB of memory (or was it 2
or 3?). A 64-bit application can use a whole lot more (like 16 petabyte...).

You will not run out of memory just because the application uses more
memory than there is physical memory, as the memory is virtual and can
be swapped to disk. Rather you get the exception when you are trying to
use more memory than the application can address.

For a 32-bit application you would reach this limit right about when you
have used a little more than there is physical memory, but a 64-bit
application will have no problem adressing the memory so it will instead
reach the point where the application pool can't accept the memory usage.
 
A

Arto Viitanen

Ethan said:
Thanks Pete.
I was actually kind of surprised that I could actually catch the exception
when I first did. I thought that if it was out of memory, how can I tell it
what to do??

I don't know about .NET, but on Java the system has some preallocated
out of memory exception objects, so it does not have to allocate them
when the memory is run out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top