Potentially Shared Code - Multiple entries for same dll

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
Nikhil
Posts: 2
Joined: Thu Nov 11, 2010 9:57 pm

Potentially Shared Code - Multiple entries for same dll

Post by Nikhil » Thu Nov 11, 2010 10:19 pm

Hi,

I am using .Net Memory Profiler 3.5 professional edition. After taking a snapshot of our application I am looking at the data presented by the "Native Memory Tab. The "Potentially shared" node has a "Code" section that lists the assemblies that out application is using. I see that it has duplicate entries for the same assembly.

For example I see two entries for the System.dll with different size information:

\Device\HarddiskVolume1\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll 1008 KB
C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll 540 KB

Can you please explain why there are multiple entries? How can I get the information about the total memory allocated per assembly.

Thanks
Nikhil

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

Re: Potentially Shared Code - Multiple entries for same dll

Post by Andreas Suurkuusk » Fri Nov 12, 2010 1:45 pm

.NET Memory Profiler calculates the memory used by a .DLL-file by using the full path of the file. Depending on how the file has been loaded into memory, e.g. by using MapViewOfFile or using LoadLibrary, the path can be different even if it represents the same file. We will look into this and see if it can be improved, e.g. by detecting that two paths actually represent the same file and then combine the data for both paths.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Nikhil
Posts: 2
Joined: Thu Nov 11, 2010 9:57 pm

Re: Potentially Shared Code - Multiple entries for same dll

Post by Nikhil » Fri Nov 12, 2010 5:54 pm

Thanks for you reply but can you please clarify the following point:

On my machine the System.dll has a size = 3,149KB, but the profiler is reporting following information:

\Device\HarddiskVolume1\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll 1008 KB
C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll size 540 KB

How come when System.dll is loaded the actual size of the assembly is not reported as Code? Also can you clarify what the numbers 1008 KB and 540KB reported by the profiler represents?

Thanks
Nikhil

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

Re: Potentially Shared Code - Multiple entries for same dll

Post by Andreas Suurkuusk » Sun Nov 14, 2010 10:24 pm

Not all parts of an .dll is made up of code, so only parts of the .dll will be presented as Code in the native memory view. For example, a .NET assembly also contains metadata information, such as types, method and property data, which will not presented as Code, but rather as data. Additionally, it is not certain that the whole .dll is mapped into memory, only parts that need to be accessed have to be mapped.

Actually, it's a bit odd that data in System.dll is mapped as code, since System.dll contains IL-code, which is not actual x86/x64 code as it must first be JIT-compiled (or loaded as a ngen-image), but that's probably an implementation details in the .NET runtime.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests