Martijn
Martijn

Reputation: 24789

How can I see which dll's are loaded by my application?

I'd like to know how I can see which dll's are loaded by my application. I want to know this because the application consumes a lot of memory, about 400-500 MB (private bytes).

I've profiled my application with memprofiler for .NET, but I couldn't find any memory leaks, so I thought maybe there are some dll's loaded which are very big. If this is the case, I can justify the memory usage of my application.

I hope you can help me.

Edit: For my information: Say foo.dll on the hard drive is 2MB. When this dll is used and loaded in my application, does this file also take 2MB of memory?

Upvotes: 1

Views: 8936

Answers (6)

L.B
L.B

Reputation: 116118

var modules = Process.GetCurrentProcess()
                .Modules
                .Cast<ProcessModule>()
                .Select(m=>new {Name = m.ModuleName, Size = m.ModuleMemorySize })
                .ToArray();

Upvotes: 3

Alexei Levenkov
Alexei Levenkov

Reputation: 100547

In Visual Studio check out Window->Module view while debugging your application. You'll see all loaded modules.

It is unlikely that you have enough DLLs to use so much address space. Lack of memory leaks does not mean you have no objects that you don't need. If you need to find out what takes memory - careffully look what objects are allocated, also estimate how much memory your program should be taking (i.e. loading 100Mb XML file and expecting 100Mb memory usage is unrealistic).

Upvotes: 1

squelos
squelos

Reputation: 1189

No, it is not because your .dll file is 2mb on hard drive that it will only use up 2mb of memory. A dll is simply a program. So its just like having a .exe that is 2mb in size. It can easily use up 2gb if it does massive calculation and allocates a lot of memory :)

Edit : As said below, the memory used up by loading the DLL is negligeable compared to the memory allocated during runtime. So as stated, use a profiler to see where all that memory is going !

Upvotes: 0

Andre Loker
Andre Loker

Reputation: 8408

The size of an executable on disk does not say how much memory it will need at runtime. You can have a tiny application that allocates large amounts of memory for example.

Whether 400-500 MB is too much for your application depends on what you're doing, of course. The largest part of this won't be caused by DLLs being loaded but by memory allocated at runtime. Try to use a profiler that shows you which type of object allocates how much memory in your application. This often already tells you where to look.

Upvotes: 2

Sascha Berlin
Sascha Berlin

Reputation: 106

tasklist /m on commandline shows at least the loaded dlls of each applications running. whats missing is the information of the memoryusage of each dll.

Hope that helps a little Sascha

Upvotes: 1

Random Dev
Random Dev

Reputation: 52280

if you are running on win7/vista(?) or similiar you can check the resource-monitor / CPU/Associated Modules tab:

enter image description here

Upvotes: 5

Related Questions