Several questions about Memory Profiler

Memory profiling for .NET developers

Moderators: StephenC, Alex.Davies, AndrewH, melvyn.harbour

Several questions about Memory Profiler

Postby RinkeB » Tue Aug 02, 2011 2:55 pm

Hello there,

After reading the articles on the .NET tools resource center page, I still have a few questions about the Memory Profiler application.
For your information, I installed the application on a virtual server (Win 2008 with IIS) and I am profiling the memory usage of asp.net MVC applications.

I was wondering why there are thousands of string objects and hundreds of Byte[] and Int32[]? Most of them are not my code. Where do they come from?

And what does the 'Number of large fragments' section under the title 'Memory fragmentation' mean? Because it shows 2 (100% of free memory). What exactly is this?

Greetings,
RinkeB
 
Posts: 5
Joined: Tue Aug 02, 2011 11:14 am
Location: Leeuwarden

Postby Brian Donahue » Wed Aug 03, 2011 4:59 pm

Hello,
Unfortunately in order to understand the problem this will require a deep understanding of web applications, rather than profiler. However, I can tell you that, since web applications almost exclusively return data that is of type "string", for instance, HTML pages, invariably the type with the most instances will be string. This doesn't mean something is wrong. It means the .NET runtime is producing these.

If you can please back up and let us know what kind of problem you think you may have with this website, we can give better advice about what you may need to look at to find the problem.

Lots of websites are problematic by nature because they store state too long or start to thrash when they reach their limit of simultaneous sessions.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby RinkeB » Thu Aug 04, 2011 9:31 am

Well my problem is the following. I'm profiling MVC websites of our company to see if I can lower the memory usage.

Even the most simple websites are already using 32mb, and a simple statistics application for running processes constantly uses 50-60mb.
I am talking about private bytes here.

In the summary section the program shows '.NET is using 6,195mb of 27,35mb total private bytes allocated to the application'.
In my understanding these numbers are explained as following:

6,195mb = gen1 + gen2 + large object + unused mem.
27,35mb = the above + unmanaged.

And the total size of objects in snapshot X = gen1 + gen2 + large object.

Are my assumptions true?

I am wondering how private bytes can be that high.
Where does the increase come from in comparison to the numbers i've just given.

And I think i've posted this topic in the wrong section. Shouldn't it be in the normal Memory Profiler section? I am using 7.0.
RinkeB
 
Posts: 5
Joined: Tue Aug 02, 2011 11:14 am
Location: Leeuwarden

Postby Brian Donahue » Thu Aug 04, 2011 9:36 am

I don't think the memory usage you see in the web app is that extreme, to be honest. And as you pointed out it's mostly unmanaged, so probably stuff IIS uses internally that you can't do a thing about.

I think Andrew had delivered a pretty thorough explanation you may be interested in.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby RinkeB » Thu Aug 04, 2011 10:22 am

Andrew is mostly talking about Virtual Bytes, which isn't the issue here I think.

I'm still wondering what's the difference between the the private bytes in the line graph (~50mb) and the private bytes on the top of the summary page (26,38mb).

picture

What does explain this difference?
RinkeB
 
Posts: 5
Joined: Tue Aug 02, 2011 11:14 am
Location: Leeuwarden

Postby Brian Donahue » Thu Aug 04, 2011 10:33 am

I think this is one of those cases where the performance counter is wrong because it doesn't update until after garbage collection.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby RinkeB » Fri Aug 05, 2011 8:30 am

Well, when I force a garbage collection by taking a snapshot, the counter decreases some, but there is still a big difference between the two numbers. This is the case for every MVC project I profile. Can I assume the counter is wrong for all projects of this kind or is there something else going on?
RinkeB
 
Posts: 5
Joined: Tue Aug 02, 2011 11:14 am
Location: Leeuwarden

Postby Brian Donahue » Fri Aug 05, 2011 10:01 am

There is another discussion about the discrepancy here: http://www.red-gate.com/messageboard/vi ... 3481#33481
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby RinkeB » Thu Aug 11, 2011 2:06 pm

No: private bytes includes free space on the .NET heaps as well as unmanaged memory usage. You can find out which is responsible by looking at the breakdown at the bottom of the snapshot summary page: the free space on all .NET heaps value is included in the private bytes.

So what explains the difference between the value in the line graph and the value in the summary box? The line graph includes all free space reserved by the whole of .NET?
I'm still quite confused about this. Sometimes the line graph value is twice as big as the summary value.
I hope you can give me some info on this, because i encounter this at all my MVC applications.
RinkeB
 
Posts: 5
Joined: Tue Aug 02, 2011 11:14 am
Location: Leeuwarden

Postby Brian Donahue » Thu Aug 11, 2011 2:19 pm

The answer is yes, it's just that simple. Once set of data is Profiler tallying up the size of the objects and the other is the performance counter data (nothing to do with us, it is generated by Windows) which includes all of the unmanaged resources, and ANTS is not capable of tracking those resources. In either case the data is not for all of .NET but the private bytes size in the performance counter includes the .NET runtime loaded into the process.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am


Return to ANTS Memory Profiler Previous Versions

Who is online

Users browsing this forum: No registered users and 1 guest