ironmansoftware / RuntimeDiagnostics

.NET Runtime diagnostic cmdlets.
MIT License
10 stars 1 forks source link

Statistics parameter not found #1

Closed PanosGreg closed 9 months ago

PanosGreg commented 1 year ago

The Statistics parameter does not exist in Get-ClrObject

I'm trying the following as per the readme.md

$Process = Debug-ClrProcess -ProcessId $PID
$Runtime = $Process | Mount-ClrRuntime
$Runtime | Get-ClrObject -Statistics | select -f 10

And I'm getting the error:

Get-ClrObject: A parameter cannot be found that matches parameter name 'Statistics'.

Module version: 0.0.1 PSVersion: 7.3.4 Windows 10 22H2

PanosGreg commented 1 year ago

Hi Adam,

Hope you are keeping well.

By the way, it would be very helpful if you can also make a short YouTube video showcasing the functionality of this module.

I understand this module is a work based on what you've shown here but doing that in PS now, which is indeed a very good addition and very much appreciated.

Panos

PanosGreg commented 9 months ago

I eventually went through the C# code of this repo which then lead me to the source clrMD repo from Microsoft.

So I ended up writing a function that uses the latest version of the RuntimeDiagnostics .dll's and calculates the memory sizes and counts for each .NET object here:

Get-RuntimeDiagnostics

Here's the output when I run it in PowerShell v7.4.1

C:\> Add-Type -Path (dir 'C:\RuntimeDiagnostics\*\lib\netstandard2.0\*.dll').FullName
C:\> . C:\Scripts\Get-RuntimeDiagnostics.ps1
C:\> 
C:\> Get-RuntimeDiagnostics -NumberOfItems 5 -Verbose

Memory  Count Type
------  ----- ----
10.7MB 116989 System.String
2.2MB   54401 System.Collections.Concurrent.ConcurrentDictionary<System.String, System.Management.Automation.CommandTy…
1.45MB  45349 System.Management.Automation.Language.InternalScriptExtent
861KB    1120 System.Collections.Concurrent.ConcurrentDictionary<System.String, System.Management.Automation.CommandTy…
728KB    6996 System.Reflection.RuntimeMethodInfo

VERBOSE: Memory started at 71MB, peaked at 139MB, and ended at 95MB, thus used 23MB
C:\> 

So I think we can close this issue.