Search code examples
c#unity-game-enginememoryvisual-studio-2019visual-studio-debugging

Debug -> Windows -> Memory for a Unity project?


I need to inspect memory content for a Unity project while debugging it.

No matter what I try, such as Use managed compatibility mode, the Memory window desperately shows:

Unable to evaluate the expression.

Question:

Is it possible at all to inspect memory using the Memory window for a Unity project?


Solution

  • Debug -> Windows -> Memory for a Unity project?

    Actually, in unity project,memory window cannot catch managed code automatically, you should use Watch Window to get the address of the variable and then input the address on Memory Window to get it.

    Suggestion

    First of all, please enable these options from this document.

    1) set a breakpoint on the variable of Unity project and when the breakpoint be hit, you could open Watch Window, and use & to get the address of variable like this:

    enter image description here

    2) Then copy the address in the Memory Window and you can see the memory content about it:

    enter image description here

    Besides, you could also try to use Unity Profiler just as Lotan recommended to watch the memory content.