Determine memory usage of object graph in .NET -


Out of curiosity - We want to know what happens in our application - and partly to us some potential issues Need to find our code, I want to track some common values ​​during the runtime of our web applications. This includes allocated memory of some object graphics in particular.

Our application keeps some data permanently in memory so that it is available to be reliable. It can be limited to several GB memory, while other applications that do almost the same stuff allocate only one or two.

Due to the required performance, we can not attach memory operators during the runtime, so it would be great to analyze the object graph on the runtime so that in some parts of the data to print it so big And that which is not so big, it will help us understand better what happens to our data and the behavior of our applications is potentially an application. Will Ulit.

Object graph means starting with fixed objects, measuring its size, all the properties, fields, all the elements with lists, all the referenced objects By following and adding their respective sizes, we have the information that how much memory is used by this object and all related objects.

Actually, I would like to answer this question: When I leave the last reference of this anchor object, how much stronger will it be when cleaning this object graph with the next object?

If you are not using a profiler then you are ready for a difficult task.

In response to a question, the question about measuring the size of an object graph has been raised several times, such as:

< / P>

got a bunch of answers (feel free to read from them) but to be honest they all suck more or less, you have to admit that there is no reliable way to get this information because This is an implementation description.

But suppose that is not really accurate measurement for you, but some ballpark figures know that "Big Boy Objects" are there.

  • Serialize your object graph

    I can imagine that the simplest way is to serializing your objects. Check with the binary format in the stream and its size.

    • Use dump files

      Another way might be to create dump files of your application and analyze memory Using them for Visual Studio 2013 is a new Memory Analyzer that helps you understand the .NET memory usage of your applications from .dmp files collected on production machines.

      It also shows you the size of all the objects:

      image here </ P> <p> Part 2: </ p> <ul> <li> Enter the description

      There is a two-part introduction on this:

      Part 1:

      part 2:

      • Use Microsoft.Diagnostics.Runtime "CLR MD"

        CLR MD is a C # API that is used to create a diagnostic tool. And the faster C # API gives the power and flexibility of what the SOS and PSSCOR debugger extensions can do.

        There is an example of a non-linear pile walker in the deucleation on GITUB, which calculates the size of an object, it acts as objsize in SOS, so that this command can be an object Takes the form of an object (calculates a parameter and the number of objects that keep it alive, as well as the reports (the total size of all objects survive.)

        < / Div>

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -