4

I have a website which executes simple MDX queries and produce output. This output is used to generate excel file. I used ANTS profiler and came to know that large amount of memory is consumed by unmanaged resources. Check the below image:

(Full size image)

What should I do next to detect such memory leaks. I want to find out why these obejcts are still alive in memory. Please suggest what should I do next.

enter image description here (Full size image)

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
SharpCoder
  • 18,279
  • 43
  • 153
  • 249
  • 4
    Just make sure to dispose everything, nothing more you can do. – Shadow The GPT Wizard Apr 03 '13 at 09:37
  • @ShadowWizard: Thank you for reply. I am calling dispose method explicitly. On what basis you said nothing else is required (I am trying to understand your though process on this). The problem is after the file is generated, app pool still holds lot of memory. I am not sure what kind of objects are retained and why. – SharpCoder Apr 03 '13 at 09:42
  • The objects might contain properties which are also COM and need to be disposed before the parent object is disposed, usually the documentation will tell such things. The only way I know of to say "this object is no longer required, remove it from memory" is to close/dispose it that's the basis for my previous comment. In .NET there is garbage collection though, so calling `dispose()` won't release the memory instantly, give it few minutes or call `GC.Collect()` yourself though I'm not sure it's relevant for unmanaged components. – Shadow The GPT Wizard Apr 03 '13 at 09:59

1 Answers1

0

I experienced a similar issue. I don't have a solution for detecting the memory leak, but I'll let you know the path I chose. Instead of calling the MDX directly from the page, I moved the MDX queries to a SQL stored procedure which returns a resultset that I can use as if it were a relational query.

CREATE procedure [dbo].[executeMdxQuery]
as
Declare @sql nvarchar(max) = '  SELECT a.* FROM OpenQuery("MY_SERVER",'' 

with member [Measures].[Fiscal Calendar Level] as ' --- remaining MDX 

exec sp_executesql @sql 
GO

Hope this helps

InbetweenWeekends
  • 1,405
  • 3
  • 23
  • 28
  • Thank you for reply. Any idea how/why executing an MDX query using store procedure would help. I will try this option and let you know the result. Thank you once again. – SharpCoder Apr 30 '13 at 04:36
  • I believe it's because SQL is processing the query natively, rather than running it through IIS and all of the layers in between to your SSAS server. – InbetweenWeekends May 01 '13 at 19:54