[英]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.