How to diagnose memory allocations on Mono platforms?
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 404
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 35
Description
## Background and Motivation
I'm looking at a .NET MAUI sample on Android:
* https://github.com/dotnet/maui/issues/23991
It is loading a periodic table, but running many GCs:
```
[riodictablemaui] Explicit concurrent copying GC freed 933(127KB) AllocSpace objects, 31(4092KB) LOS objects, 49% free, 4423KB/8846KB, paused 1.328ms,169us total 33.513ms
[riodictablemaui] Explicit concurrent copying GC freed 722(46KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 4581KB/9162KB, paused 1.856ms,170us total 14.835ms
[riodictablemaui] Explicit concurrent copying GC freed 641(43KB) AllocSpace objects, 1(108KB) LOS objects, 49% free, 4525KB/9050KB, paused 1.420ms,176us total 14.112ms
[riodictablemaui] Explicit concurrent copying GC freed 619(41KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 4579KB/9158KB, paused 1.263ms,173us total 13.825ms
[riodictablemaui] Explicit concurrent copying GC freed 483(29KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 4630KB/9260KB, paused 1.379ms,171us total 14.170ms
... repeats many more times
```
I would like to investigate this sample on the .NET side, and understand who's allocating so much. I'm able to investigate allocations using Android Studio on the JVM side:

I tried using `dotnet-trace --profile gc-verbose`, but it doesn't look like GC-related events work on the Mono runtime.
I was looking here, maybe some GC events work, and there is a way this might work currently?
* https://github.com/dotnet/runtime/blob/eb9c01f844b15115ba87071ed6952664c3ee4c95/src/coreclr/vm/ClrEtwAll.man#L9457
## Proposed Feature
What I would like is some report:
* Allocations (in bytes) per assembly, namespace, type, etc.
* Ability to see the stack trace, where the object was allocated
## Usage Examples
I think ideally, `dotnet-trace --profile gc-verbose` would work to align with this existing doc on CoreCLR:
* https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-trace
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.