0

I have an app which consumes a lot of real time data, and because it's doing so much it's quite slow under the VS 2010 and this causes it to fail in various ways.

So I was wondering if there's any way other than this profiler that I can find out how much memory in bytes say is allocated to each type in memory and dump this out periodically?

It's quite a large application so adding my own counters isn't really feasible...

Oded
  • 489,969
  • 99
  • 883
  • 1,009
user555265
  • 493
  • 2
  • 7
  • 18
  • 1
    Use the [CLRProfiler](http://www.microsoft.com/download/en/details.aspx?id=16273) or another memory profiler. – George Duckett Jan 25 '12 at 10:32
  • Thanks guys, i had concurrent GC on so i removed that and i'm using CLR Profiler, i tried some of the others but i think there's too much performance hit (at least the way i configure them) so my app ends up e.g. losing connections to things while the memory is being dumped.. CLR Profiler seems the best so thanks! – user555265 Jan 25 '12 at 12:14

3 Answers3

2

You need to use a memory profiler.

There are many around, some free and some commercial.

Also see What Are Some Good .NET Profilers?

Community
  • 1
  • 1
Oded
  • 489,969
  • 99
  • 883
  • 1,009
0

There is no easy general purpose way of saying GetBytesUsedForInstance(object), but it depends what you need the data for (unless all your types are value types, in which case it should be relatively simple).

We have an in memory cache for part of our application. We care most about relative amounts of memory used - ie the total cache size is twice what it was yesterday. For this, we serialize our object graphs to a stream and take the stream length (and then discard the stream). This is not an accurate measurement of "how much memory a type uses up" per se, but is useful for these relative comparisons.

Other than that - I think you are stuck using a profiler. I can highly recommend SciTech Memory Profiler - I use it a lot. It integrates well into Visual Studio, is fast (the latest version is anyway), and gives tremendously useful detail.

Rob Levine
  • 40,328
  • 13
  • 85
  • 111
0

I would suggest like for getting a general information massively use Process Explorer. One time you gfigure out you need to understand the stuff deeper (what kind of objects are on heap, for example) , the best tool I used for profiling is JetBrains Memory and Performance profiler. This one is payed only.

If you need only performance profiler, there is really good free option Equatec Performance profiler

Good luck.

Tigran
  • 61,654
  • 8
  • 86
  • 123