Unmanaged memory is huge but breakdown only shows small fraction of it

Hi, I am trying to debug our application to see why it's using so much memory and becoming unusable.
The problem seems to be that there's a very large amount of unmanaged memory, but I can't figure out where the bulk of it is coming from.
This image should give a good summary of the problem I'm having:


So there is 2.951 GB of unmanaged memory in the pie chart, yet the breakdown only comes in at ~348MB

I can explain some of this, because we have some managed C++ code that creates a few memory pools at the beginning of the application, but this will only account for 952MB

So there is 952MB for our custom memory pools, ~348MB from the unmanaged breakdown, which totals 1300MB, still a huge amount away from the 2.95GB shown in the pie chart.

Is there a way I can find out where this memory is being allocated?

Thanks
Tagged:

Answers

  • Hi @dominicmclarke,

    Regarding your query, the profiler results will normally show an unmanaged memory summary that is greater than the total of unmanaged memory breakdown because the breakdown does not include the memory used by the stack (the stack memory usage usually increases when the number of threads increase).

    Just some more detailed information on the difference: the information in the pie chart is obtained by analyzing the application's entire virtual memory usage when the snapshot is taken using Windows APIs, and so it should include everything, including the stack. The breakdown on the right is based on our detection of memory allocations and attempts to allocate them to a particular module which was on the stack at the time. It should contain most allocations on the heap and allocations of pages of virtual memory requested by the application (excluding heap allocations before the profiler started, or commits of virtual memory pages reserved before the profiler started), but doesn't necessarily take into account things such as the stack.

    Eventually, we want to show information about the stack usage in the module breakdown so that when the breakdown values are added up, they do total up to the same pie chart value, though this may not be in the immediate future, I'm afraid. For now, the pie is the most complete and accurate overview of unmanaged memory usage. However, the unmanaged breakdown can still help to identify if for example, a certain module's code is requesting large blocks of unmanaged memory and neglecting to free it again.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
Sign In or Register to comment.