开发者

Getting an out of memory exception with System.Threading.ReaderWriterCount

开发者 https://www.devze.com 2023-01-23 02:10 出处:网络
I\'ve got an asp.net application, it\'s running on DotNetNuke, under load we get the occasional out of memory exception.

I've got an asp.net application, it's running on DotNetNuke, under load we get the occasional out of memory exception.

I've got a dump loaded it into windbg.

the end of !dumpheap -stat is

1192a588    88684      2128416 AutoMapper.MappingEngine
79333594     9482      2266348 System.Byte[]
134b0034    88695      2838240 System.EventHandler`1[[AutoMapper.TypeMapCreatedEventArgs, AutoMapper]]
13d8703c    88684      4611568 System.Collections.Generic.Dictionary`2[[Castle.DynamicProxy.Generators.CacheKey, AutoMapper],[System.Type, mscorlib]]
13d86dc8    88684      4611568 Castle.DynamicProxy.ModuleScope
13d865bc    88684      4611568 System.Collections.Generic.Dictionary`2[[AutoMapper.Internal.TypePair, AutoMapper],[AutoMapper.IObjectMapper, AutoMapper]]
79327434    88703      4612556 System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Int32, mscorlib]]
6c38e4e4    88684      5675776 System.Threading.ReaderWriterLockSlim
79330b24    87736      6458012 System.String
000d9c88      129     24186884      Free
793042f4   221202    101117016 System.Object[]
6c38e4a0 22703104    544874496 System.Threading.ReaderWriterCount

I can't find much inform开发者_如何学JAVAation on the System.Threading.ReaderWriterCount, as it seems to be the problem.

What is the likely cause? Or failing that what's the best next step to work that out?

Based on the pointer from the given answer I had a look at ReaderWriterLockSlim. I wasn't using it directly, but I saw that it had 88684 instances, digging deeper I saw quite a few classes with that number of instances, pointing to AutoMapper.MappingEngine. This should be a singleton, so I've had a look at where it's being created. I suspect that it's the DI container and have made some changes around that to see if it helps


ReaderWriterLockSlim is not a cheap class in memory footprint - that could be why your ReaderWriterCount instances are proliferating. See here for detailed info from Reflector.

Can you reduce usage of this class? Maybe not all of them need to be Read/Write Locks, simple Mutex/lock() might work?

Note also that this class is IDisposable - perhaps you are not Dispose()-ing of them after you are through with them?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号