« Scammers: The Nerve!Offense-Taking In The Skeptical Community »

Running Out Of Memory Without Using Much Memory In C#

12/16/11

  04:06:42 pm, by Nimble   , 236 words  
Categories: Programming

Running Out Of Memory Without Using Much Memory In C#

Few things are more dreadful for an application than a recurring "out of memory" error.

You ask for memory graphs for the past hours or days and scan them... and you don't find anything untoward. Now, you're really confused.

One thing about the memory management in .NET - you do not actually have to be using all the memory to get a System.OutOfMemoryException.

We had a server application blowing up with just around 1 Gb of memory used, when we have seen much more than that with load testing with no issues.

In our particular case, the culprit was AppDomains. We create them to safely host external libraries written for .NET. AppDomains are finalized, and it seemed reasonable - based on that and the fact that they do not figure prominently in memory tools - to let .NET take care of them as they go out of scope.

The out of memory exceptions were happening inside CreateDomain almost exclusively. This might be due to the memory being "reserved" somehow, or it could just be that CreateDomain looks for some other resource - or space on a list for a resource - that the .NET runtime can no longer provide.

We cannot easily tell which, since the error occurs inside nCreateDomain. It's a [MethodImpl(MethodImplOptions.InternalCall)] - meaning part of the CLR itself.

So, we used AppDomain.Unload(...) with those application domains when the sessions ended, and the out of memory issue - fingers crossed - has seemingly disappeared.

No feedback yet

April 2023
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Jade Annand's blog of everything except sports (...and who knows? I may break that rule some day)

Search

  XML Feeds

powered by open-source CMS software

An unexpected error has occurred!

If this error persists, please report it to the administrator.

Go back to home page

Additional information about this error:

MySQL error!

Table './nimblebr_b2evolution/evo_hitlog' is marked as crashed and should be repaired(Errno=145)

Your query: Record the hit

INSERT INTO evo_hitlog ( hit_datetime, hit_uri, hit_disp, hit_ctrl, hit_action, hit_type, hit_referer_type, hit_referer, hit_referer_dom_ID, hit_keyphrase_keyp_ID, hit_keyphrase, hit_serprank, hit_coll_ID, hit_remote_addr, hit_agent_type, hit_agent_ID, hit_response_code, hit_sess_ID )
VALUES ( FROM_UNIXTIME( 1680428771 ), '/index.php/running-out-of-memory-without-using-much-memory-in-c?blog=2', 'single', NULL, NULL, 'standard', 'direct', '', NULL, NULL, NULL, NULL, '2', '34.232.63.94', 'unknown', NULL, '200', '11009154' )