Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure pooled objects memory #1579

Closed
timcassell opened this issue Oct 30, 2020 · 3 comments
Closed

Measure pooled objects memory #1579

timcassell opened this issue Oct 30, 2020 · 3 comments
Assignees
Labels

Comments

@timcassell
Copy link
Collaborator

I love the fact that I can see how much memory is allocated on each run with the MemoryDiagnoser. What I'm missing, though, is measuring the difference in memory before a benchmark, and after (i.e. how much memory is perpetually consumed from pooled objects). Is there a way I can measure this now?

@adamsitnik
Copy link
Member

Hi @timcassell

Is there a way I can measure this now?

To get this detailed information you need to use a memory profiler.

The memory profilers that I can recommend:

Once you choose the one that you like, you need to:

  • take a memory snapshot of your app (using the profiler)
  • perform the operation that you want to investigate
  • take another memory snapshot
  • use the profiler to show you the diff between two snapshots

By doing this you will get all the objects that have been allocated and survived the cleanup (like caches etc). This is also the way of finding memory leaks ;)

Since this is a memory profiler feature and we don't plan to add it to BenchmarkDotNet, I am going to close the issue.

Thanks,
Adam

@adamsitnik adamsitnik self-assigned this Oct 30, 2020
@timcassell
Copy link
Collaborator Author

Hm, I was hoping to be able to add it to the summary table. It seems I can get the data in code through the process (GlobalSetup/GlobalCleanup seem like good places to do it)... is there a mechanism to add custom data to the summary table? It would be nice to have that happen automatically rather than manually doing it for each run.

@adamsitnik
Copy link
Member

In this particular case, you would need to implement your own diagnoser. You can use EtwProfiler as an example.

In other cases, you could implement a custom column: https://benchmarkdotnet.org/articles/configs/columns.html#custom-columns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants