c# - How to find out memory consumed by classes, objects, variables, etc -
this question has answer here:
- how object size in memory? [duplicate] 7 answers
i trying play memory profiling (for first time, please forgive ignorance), see how memory consumed classes, objects, variables, methods etc. wrote sample c# console program called memplay.exe:
using system; using system.text; namespace memplay { class program { static void main(string[] args) { someclass myobject = new someclass(); stringninemethod(); } private static void stringninemethod() { string somestring0 = "abcdefghijklmnopqrstuvwxyz"; string somestring1 = string.empty; string somestring2 = string.empty; (int = 0; < 9999; i++) { somestring1 += "9"; somestring2 += somestring1; } } } class someclass { } }
once program ran, want find out:
how memory consumed by
- memplay.exe
- program class
- someclass
- main method
- myobject
- stringninemethod
- somestring0
- somestring1
- somestring2
and how processor used by:
- memplay.exe
- main method
- stringninemethod
i tried using visualstudio's 'performance diagnostics' tool, can see how memory used whole function (i.e. main method, stringninemethod, , string.concat method).
is there way/tool can me see details of how memory each variable, object, class, method consumed? in advance.
edit: no question not duplicate of question suggested, question trying object sizes @ runtime, asking how can information after program has ended. visual studio's performance diagnostics tool does, gives information after program has ended execution.
i use 1 : redgate ants
i've used 1 in past : scitech memory profiler
they both have free trials , worth at. i've been impressed enough @ various times buy versions of both.
(i don't work either company - recommending has worked me - there other tools out there such jetbrains memory profiler, i've not tried , can't offer opinion).
Comments
Post a Comment