开发者

C#: How much RAM does an object with all sub-objects need? Get list of needed RAM for object?

开发者 https://www.devze.com 2023-01-09 01:53 出处:网络
is there a way to get, for debug开发者_C百科ing purpose, a list of needed RAM for all my objects incl. sub-objects and so on, written to a text-file?

is there a way to get, for debug开发者_C百科ing purpose, a list of needed RAM for all my objects incl. sub-objects and so on, written to a text-file?

I need to get these values while running in production mode without visual studio running. For example every x minutes. Is this possible? How can I do that?

Thank you very much in advance,

Chris


Load windbg and load sos.dll, and attach to process.

log the output to a file then do a !DumpHeap -stat (and variants)

psscor2.dll can dump the heap to an xml file. (or one for use with ClrProfiler)


You can use JetBrains DotTrace to do the memory profiling. Its only 30 days trial but what a great tool to navigate through specific in-memory objects.


You can create a tool, that will monitor size of process.
Or do this in seperate thread of running application. Process.GetProcessesByName()...


For value types, you should be able to use sizeof(). I don't think there is an equivalent for reference types, though. Note you can only use sizeof() inside an unsafe block.

0

精彩评论

暂无评论...
验证码 换一张
取 消