Page 1 of 1

Native memory very large, can't figure out why!

Posted: Fri Apr 04, 2008 12:09 am
by dankarmy

I have recently downloaded v3.1 of memory profiler.

When profiling my web app, it says the total number of live bytes is around 1.9mb. However when I switch to Native memory tab - physical memory is at 49,850kb and committed memory is at 89,120kb. Which seems incredibly high!


Physical memory:

Private > Code (3,868kb)
Private > Data (30,440KB)

Shared > Code (3,492)
Shared > Data (876kb)

Potentially shared > Code (10,212kb)
Potentially shared > data (964kb)

Now if I expand the Private > Data node i see an entry "<Unidentified>" and sitting at 29,664kb! What does this mean?



Posted: Fri Apr 04, 2008 3:21 pm
by Andreas Suurkuusk
The <Unidentified> node represents allocated memory that the profiler has not been able to identify.

Do you have the resource tracker enabled? If not, then I recommend that you enable it. The data collected by the resource tracker will be used to identify additional native memory.

You can read more about the <unidentified> node in my blog at: ... ther-node/

Note that when I wrote that post the node was named <Other> and data collected by the resource tracker was not used in the native memory view.

Posted: Fri Apr 04, 2008 4:37 pm
by dankarmy

You can see from this that there is over 12mb in virtual memory, 5mb in Heap Memory and 2mb in Local Memory.

What do you suggest I look for next?



Posted: Mon Apr 07, 2008 2:34 pm
by Andreas Suurkuusk
You can get more information about the unmanaged memory usage by investigating the allocation stacks of the Virtual memory and Heap memory. If the memory usage is caused by your application, the call stacks might give you an idea about what's causing the memory usage.

I don't think that the unmanaged memory usage is unreasonable for an ASP.NET application, unless the memory usage keeps increasing. In your screenshot the memory usage increased with about 70KB between the snapshots, which does not sound too much. Does the unmanaged memory usage increase over time?

Are you still seeing a lot of unidentified memory in the Native memory view?

Posted: Tue Apr 08, 2008 10:22 am
by dankarmy

Thanks for coming back to me.

Yes over time, say if I click simulate the user natural progression through the site (maybe 20 pages or so) the memory peaks at around 100mb:


I have viewed the call stacks for the Heap Memory, but can't see any user code. I dont recognise any of those lines:


Any Ideas?


Posted: Tue Apr 08, 2008 11:04 am
by suvetar
I've had similar experience in my companies App.

Are you dynamically loading UserControls or something like that? I have lots of assembly parsing because of that as our product is designed to generate pages dynamically and on-the-fly.

You might also notice that the non-public pool in the ASP.Net Cache has lots of data in it, that you didn't put there. That's the Assembly loader/parser caching itself.

Posted: Wed Apr 09, 2008 9:57 am
by Andreas Suurkuusk
As suvetar mentions, dynamically generated classes will cause additional unmanaged memory usage. The memory usage for these classes will not be reclaimed until the application domain is unloaded.

The call stack for the HeapMemory instance indicates that it was created while loading an assembly. Whether this is the main cause for the high memory usage I don't know. If you investigate the details of the Heap Memory resource you might get more information.

However, considering the complexity of the ASP.NET framework and the .NET runtime, I don't think the memory usage is too excessive. If the profiler induced data is excluded, the private working set is less than 35MB.