简体   繁体   中英

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?

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

在此处输入图片说明

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.

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

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

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 !

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 (ie loading 100Mb XML file and expecting 100Mb memory usage is unrealistic).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM