I have a .net project that uses C++ project and is eating a lot of memory.
I wonder if there is quick and easy way to count inflow bytes allocated by new and outflow bytes freed by delete operator. Add some logging or something.
Source code for both operator is provided by Visual Studio so I can hack it.
The problem is I can see huge VM consumption and I wanna investigate why. I tried several memory profilers but none of them can deal with unmanaged C++ allocation within .NET application
Usually memory profiling tools like Valgrnid or Rational Purify can help you profile the memory utilization of programs.
In case you still want to have your own implementation,
You can Replace the global
newanddeleteoperators by overloading them and inside your own overloaded operators you can maintain count of the memory allocated.In case you choose/are forced to follow the second option, there are certain aspects to be taken care of, You can read the details in this answer here.
If you are using STL:
The STL container classes in turn use the Global
new&deleteoperators for allocations. So If you replace thenew&deleteglobal operators then STL will use them instead of std new and delete operators.