Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine memory usage in my .NET application

I have a website where some user can upload his dll. I need to create an instance from this dll and call a specific method. Moreover, I need to do it with several dll's in 1 process, so it is not an option for me to use System.Diagnostics.Process.

Is there a way to determine how much memory does this method call use or limit it in my application runtime? Thanks in advance for any help

like image 686
Andrey Avatar asked Jan 24 '11 23:01

Andrey


People also ask

How do you analyze memory in Visual Studio?

To bring up the window again, click Debug > Windows > Show Diagnostic Tools. Choose Memory Usage with the Select Tools setting on the toolbar. Click Debug / Start Debugging (or Start on the toolbar, or F5). When the app finishes loading, the Summary view of the Diagnostics Tools appears.

How detect memory leak in .NET core application?

Examine managed memory usage. Before you start collecting diagnostics data to help us root cause this scenario, you need to make sure you're actually seeing a memory leak (memory growth). You can use the dotnet-counters tool to confirm that. You can see that the managed heap memory is 4 MB right after startup.


1 Answers

Memory usage in .Net is very difficult to gauge - It will depend on a lot of factors like whether garbage collection run, how much of the framework has been loaded, etc.

You can look at memory usage on a per-process level using performance counters

Assuming for a moment you've already considered the security implications of running a users code in a semi-trusted environment, you need to use an AppDomain to load the DLL - That way it can be unloaded without restarting the whole website / worker pool

like image 79
Basic Avatar answered Oct 19 '22 23:10

Basic