What are the challenges you face when working across database platforms? Take the survey

Several questions about Memory Profiler

RinkeBRinkeB Posts: 8
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?



  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    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.
  • Options
    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.
  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    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.
  • Options
    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).


    What does explain this difference?
  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    I think this is one of those cases where the performance counter is wrong because it doesn't update until after garbage collection.
  • Options
    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?
  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    There is another discussion about the discrepancy here: http://www.red-gate.com/messageboard/vi ... 3481#33481
  • Options
    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.
  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    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.
Sign In or Register to comment.