Ironic - .NET Memory Profiler appears to leak memory

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
rconde
Posts: 2
Joined: Fri Apr 06, 2007 4:18 pm

Ironic - .NET Memory Profiler appears to leak memory

Post by rconde » Fri Apr 06, 2007 4:20 pm

While the profile works very well at profiling applications...it appears you didn't use it to profile itself. While using it in VS2005 the process memory usage climbs and climbs never being released even after closing all memprofiler windows. Are you aware of this issue?

Rob Conde
a.i. solutions

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Sat Apr 07, 2007 8:57 am

We are aware of a minor memory leak with the profiler within Visual Studio 2005. This leak is caused by an unreleased COM-object by Visual Studio itself.

When profiling our Visual Studio package we noticed that our profiler editor window wasn't correctly GCed, which caused a major memory leak (e.g. all controls and a lot of session data was kept in memory). We then investigated a very simple sample provided by Microsoft, and we saw the same (albeit much smaller) memory leak there. It seems like Visual Studio fails to release the COM Callable Wrapper of the editor window correctly. Since we don't want to release a COM object we don't own (what if Visual Studio will actually use it at some point), our solution was to minimize the memory leak. This was simply done by setting all references in the window class to null, including references in framework classes using reflection.

I think that the total number of leaked bytes caused by this is less than <20,000, which is of course not perfect, but we decided that it was acceptable. We will continue to try to minimize this leak, e.g. by somehow making sure that the COM-object is correctly released.

Do you think that this is the memory leak you were seeing? Or are you seeing something bigger?
Best regards,

Andreas Suurkuusk
SciTech Software AB

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Sat Apr 07, 2007 12:24 pm

I just realized that the workaround we wrote for the problem with unreleased COM-objects in Visual Studio, was written after we split the code base for v3.0 and the fix was never included in v2.6. So the memory leak for v2.6 will be bigger than 10-20 KBytes. We will try to fix this as soon as possible and build a maintenance release for v2.6.

We do use the profiler on itself, but our testing has been mainly aimed at making sure that old session data is correctly GCed when a new session is started. Apparently the testing was previously lacking when it comes to Visual Studio integration. Even if the memory leak was not directly caused by us, it's a bit embarrassing that we have released a version containing this leak. Of course we have now included this in our testing to make sure that this does not happen again.
Best regards,

Andreas Suurkuusk
SciTech Software AB

rconde
Posts: 2
Joined: Fri Apr 06, 2007 4:18 pm

Post by rconde » Sat Apr 07, 2007 12:53 pm

I don't think thats the problem:

1) I'm using 3.0
2) The memory of the process grows from an initial ~200mb to ~500mb.

This is after perhaps ~10 profiling sessions (thats a very rough guess).

Rob

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Mon Apr 09, 2007 10:19 am

We were definitely not aware of such a memory leak related to Visual Studio, but we have done some additional testing and have found some problems. For instance, when you view the property pages for an active session, the property pages are wrapped in a CCW, which does not seem to be released by Visual Studio. Since editing the properties of a session requires a reference to the session, this causes the whole session to be kept in memory if the page is not properly released.

It seems like there are several problems with Visual Studio not releasing interfaces properly, so we will continue to investigate any additional problems that this might create. We will soon release an updated version of the profiler that will minimize the impact of the unreleased interfaces.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Wed Apr 18, 2007 12:04 pm

We have investigated this issue and we found that the profiler could cause a memory leak under certain circumstances, especially when running under Visual Studio. We have now released a new version of .NET Memory Profiler (v3.0.103) in which these issues are resolved. The latest release can be downloaded from http://memprofiler.com/download.aspx.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 21 guests