Wikipedia:Reference desk/Archives/Computing/2023 September 16

= September 16 =

.NET C# process memory usage utility for Windows?
Is there some kind of utility program for Windows that could attach to a .NET C# process and show as it is running, which C# objects the process is keeping in its memory and how much memory they are using at the moment? J I P &#124; Talk 18:05, 16 September 2023 (UTC)


 * A sufficiently good debugger or profiler.
 * I have no real experience with C# or .NET I'm afraid. Do .NET runtimes have debugging or profiling options? If so that might be all you need. Here's MS on .NET profiling. Some searching along the lines of "dotnet profiler" may be profitable. 47.155.41.104 (talk) 06:58, 17 September 2023 (UTC)
 * Oh also I should have mentioned this as it possibly may wind up saving you from wasting a lot of time. As noted in the MS article, if the C# code winds up itself calling into "unmanaged" (non-.NET) code, e.g. it calls into a C or C++ library, C# profiling by itself can't tell you anything apart from, the leak's in there somewhere, and a C# debugger can give you the stack trace. If it turns out the leak is in the library, if you want to diagose it you have to then switch into debugging that lib, which is more involved. Tip: you will need debug symbols for the binary loaded into your profiler/debugger (or a binary compiled with them).
 * This is distinct from either the .NET runtime, or underlying code called by the runtime like the Win32 API, leaking memory. If that happens you've probably found a bug in one of those! Might want to report it, but in the meantime you might be able to work around it. 47.155.41.104 (talk) 22:21, 17 September 2023 (UTC)