Brett
Brett

Reputation: 3538

How can I figure out how much memory a .Net Appdomain is consuming?

I'm trying to programmatically restrict the memory consumption of plugins running in a .Net AppDomain, but I can't find any setup parameters for this, nor can I find a way to query an AppDomain to figure out how much memory it is consuming. Any ideas?

Upvotes: 8

Views: 4300

Answers (4)

Björn Boxstart
Björn Boxstart

Reputation: 1168

Old question, but in the meantime (since .Net framework 4.0) a new solution is available. You will have to enable ARM (Application domain Resource Monitoring). From that point on, you can request information on total consumed processor time, memory usage etc.

See Microsoft documentation over here

Upvotes: 6

Rolf Huisman
Rolf Huisman

Reputation: 1437

Using the mscoree.CorRuntimeHostClass interop from C:\WINDOWS\Microsoft.NET\Framework\vXXXXXX\mscoree.tlb

Upvotes: 0

Ben Robbins
Ben Robbins

Reputation: 2630

Here's the documentation for querying a process's memory usage. Not the same as the AppDomain, but it might be a place to start.

http://msdn.microsoft.com/en-us/library/s80a75e5(VS.80).aspx

You can ask the GC what it thinks is currently allocated also.

http://msdn.microsoft.com/en-us/library/system.gc.gettotalmemory(VS.71).aspx

Upvotes: 0

TheEmirOfGroofunkistan
TheEmirOfGroofunkistan

Reputation: 5654

Not sure programatically, but Process Explorer can tell you how much memory a .net AppDomain is using. Maybe they have some documentation out there about how they are querying that info.

Upvotes: 2

Related Questions