views:

62

answers:

2

Is it possible that the .Net framework behaves differently when it comes to garbage collection / memory limitations on server environments? I am running explicitly x86 compiled apps on a 64bit server machine with 32gbs of physical ram and I am running out of memory (SystemOutOfMemoryException) even though nothing but that particular app is running and the server/all other apps utilize 520mb total.. but I cannot reproduce that behaviour on my own (client win7) machine.

Now I know that the app -is- memory intensive, but why is it causing problems on the server and not on the client?

+2  A: 

The OutOfMemoryException in .NET rarely (if ever) means that the machine is literally out of memory. OutOfSomeNecessaryCriticalResource would have been a less-misleading name.

The OutOfMemoryException really just means that whatever is going wrong, the programmer chose to throw that particular exception in that particular situation. For example, simply calling Image.FromFile(...) on a corrupted JPEG (or any file format that .Net can't open) will result in an OutOfMemoryException, not because .NET runs out of memory, but because that's the documented type of exception thrown for an invalid file (do not ask me why, as I don't know).

To debug your particular problem, you need to find out what is throwing the OutOfMemoryException (and where and when). An OutOfMemoryException by itself means absolutely nothing.

MusiGenesis
But most of the time an `OutOfMemoryException` indicates that a memory allocation failed. This does not mean - as you mentioned - that the machine is out of physical memory - but that there is not enough contiguous memory space available in the virtual address space of the process to satisfy the demand.
0xA3
@0xA3: as I said in my answer, all you can be sure of with an `OutOfMemoryException` is that that's the type of exception that was thrown. Personally, I have *never* encountered this exception in a .NET application as a result of my program's trying to use more memory than permitted to my process, even in .NET CF where your process is limited to 32MB.
MusiGenesis
+1  A: 

Yes, on a Windows server you'll be using a different kind of garbage collector. It is tuned more to the needs of a server style application, it collects garbage less aggressively. You can change this behavior with an app.config file, using the <gcServer> element.

That isn't very likely to be the real problem btw, I'd guess that your app sees a more realistic pattern of usage. Intentionally forcing x86 mode when you've got a nice 64-bit server is something you'd want to avoid, if you can.

Hans Passant
I'd love to -not- enfore x86 and use 'any cpu'/64bit, but unfortunately the app has to use x86 due to some legacy api's/.dlls that do not work when the parent process is a 64bit one. It's using a rather odd .net > com > java > corba path and when I use 64bit I get a BadImageFormatException once that 3rd party .net dll is being loaded.
Jörg B.