开发者

refactoring some legacy code - potential memory leaks

开发者 https://www.devze.com 2023-04-13 05:03 出处:网络
Due to so开发者_如何学运维me memory leaks, some memory is not released except when doing IISreset.

Due to so开发者_如何学运维me memory leaks, some memory is not released except when doing IISreset.

I found some code where I have a class of properties and methods, where only 10% of the methods are specific for the class, 90% can be moved to another class.

how bad is that? is this is affecting my memory, because I am initiating this class with every user using the application?

It is a ASP.NET Application on IIS6.


I suppose if the methods require no instance state but require an instance to call (i.e. they are instance methods that never reference 'this'), they could be made into static methods and save you one object allocation. However, if you have to allocate the object anyway (as it sounds like you do, for the other "10% of functionality" you mention) that doesn't sound like it will fix the issue.

You should probably do an analysis of memory usage in your application using the debugger. Rico Mariani has a pretty good blog post about tracking down managed memory leaks here: http://blogs.msdn.com/b/ricom/archive/2004/12/10/279612.aspx . It is old but still relevant. (Note: If you happen to be using .NET 4.0 you'll need to do ".loadby sos clr" instad of ".loadby sos mscorwks" to load the SOS debugger extension in WinDBG.)

0

精彩评论

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

关注公众号