简体   繁体   English

如何查看我的应用程序加载了哪些dll?

[英]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. 我想知道如何查看我的应用程序加载了哪些dll。 I want to know this because the application consumes a lot of memory, about 400-500 MB (private bytes). 我想知道这一点,因为该应用程序占用大量内存,大约400-500 MB(专用字节)。

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. 我已经使用.mmeprofiler对我的应用程序进行了概要分析,但是我找不到任何内存泄漏,因此我认为可能是某些dll加载的非常大。 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. 编辑:就我的信息:说硬盘驱动器上的foo.dll是2MB。 When this dll is used and loaded in my application, does this file also take 2MB of memory? 使用此dll并将其加载到我的应用程序中后,此文件还会占用2MB的内存吗?

if you are running on win7/vista(?) or similiar you can check the resource-monitor / CPU/Associated Modules tab: 如果您运行的是win7 / vista(?)或类似版本,则可以检查资源监视器/ CPU /关联模块选项卡:

在此处输入图片说明

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. 当然,对于您的应用程序而言,400-500 MB是否太大取决于您在做什么。 The largest part of this won't be caused by DLLs being loaded but by memory allocated at runtime. 其中最大的部分不是由DLL加载引起的,而是由运行时分配的内存引起的。 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. 命令行上的tasklist /m至少显示正在运行的每个应用程序的已加载dll。 whats missing is the information of the memoryusage of each dll. 缺少的是每个dll的内存使用信息。

Hope that helps a little Sascha 希望对Sascha有所帮助

No, it is not because your .dll file is 2mb on hard drive that it will only use up 2mb of memory. 不,不是因为您的.dll文件在硬盘驱动器上只有2mb,所以它只会占用2mb的内存。 A dll is simply a program. dll就是一个程序。 So its just like having a .exe that is 2mb in size. 因此,就像拥有一个大小为2mb的.exe一样。 It can easily use up 2gb if it does massive calculation and allocates a lot of memory :) 如果进行大量计算并分配大量内存,它很容易用完2gb :)

Edit : As said below, the memory used up by loading the DLL is negligeable compared to the memory allocated during runtime. 编辑:如下所述,与运行时分配的内存相比,通过加载DLL消耗的内存是可以忽略的。 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. 在Visual Studio中,在调试应用程序时检出Window-> Module视图。 You'll see all loaded modules. 您将看到所有已加载的模块。

It is unlikely that you have enough DLLs to use so much address space. 您可能没有足够的DLL使用这么多的地址空间。 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). 如果您需要找出占用内存的资源-仔细查看分配了哪些对象,则还应估算程序占用的内存(即加载100Mb XML文件并期望100Mb内存使用是不现实的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何包含非托管dll需要的dll(例如kernel32.dll) - how do I include dll's such as kernel32.dll which my unmanaged dll needs 如何在应用程序中隐藏DLL注册消息窗口? - How can I hide DLL registration message window in my application? 如何将WPF用户控件创建为dll,然后在另一个WPF应用程序中看到它? - How can I create WPF User Control as dll and then see it in another WPF application? 如何查看从哪个dll导入命名空间? - How do I see which dll a namespace is being imported from? 在模块窗口中,我可以看到两次使用相同路径加载的dll apear - At modules window i can see loaded dll apear twice with same path 如何确保可以加载 auth.dll? - How can I ensure that auth.dll can be loaded? 如何通知托管DLL有关托管应用程序类型的信息 - How can I inform my managed DLL about my managed application types 如何在 UserManager CreateAsync 中查看 Controller 中出现的错误? - How can I see errors which I get in my Controller in UserManager CreateAsync? 如何打开 DLL 文件以查看其中写入的内容? - How can I open DLL files to see what is written inside? 我如何在asp.net Web应用程序中调用嵌入dll中的javascript文件? - How do I call a javascript file that's embedded in a dll in my asp.net web application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM