简体   繁体   English

比较.Net和VB6应用程序的内存占用量

[英]Compare memory footprint of .Net and VB6 applications

I've been trying to compare the memory footprint between a VB6 application and .Net application. 我一直在尝试比较VB6应用程序和.Net应用程序之间的内存占用。 Trying to determine what's the average difference between the two. 试图确定两者之间的平均差异。

The .Net code is for the most part a direct translation of the VB6 and for the most part has the same instructions as they would be programmed in C#. .Net代码在很大程度上是VB6的直接转换,并且大部分具有与在C#中编程的指令相同的指令。 So while it's an apple to oranges comparison, it's a comparison on programs that are functionally (if not logically) equivalent. 因此,虽然它是苹果与橘子的比较,但它是对功能(如果不是逻辑上)等效的程序的比较。

I've been using Process Explorer to help me determine the usage of memory of the applications, however there are a few areas that have left me perplexed: 我一直在使用Process Explorer来帮助我确定应用程序的内存使用情况,但是有一些方面让我感到困惑:

  1. I've been trying to determine the overall memory consumption. 我一直在努力确定整体内存消耗。 Which of the Process Memory columns should I be using. 我应该使用哪个Process Memory列。 So far I've been looking at the Working Set ones. 到目前为止,我一直在研究工作集。
  2. For comparing the size of DLL's within an application PExplorer shows Size, WS Total and other WS counters, how can these be interpreted? 为了比较应用程序中DLL的大小,PExplorer显示了Size,WS Total和其他WS计数器,如何解释这些? And why is Size so different from WS Total, shouldn't these be the same? 为什么Size与WS Total如此不同,这些不应该相同吗?

So far I've gathered that WS Total includes both WS Private and WS Shareable. 到目前为止,我已经收集到WS Total包括WS Private和WS Shareable。 So using WS Total only can be a deceptive measure. 所以使用WS Total只能是一种欺骗性措施。 I've also read from questions such as .Net exe memory footprint that the .Net working set is usually larger than it should be. 我还从诸如.Net exe内存占用的问题中读到.Net工作集通常比它应该更大。 Would instantiating the process in a memory starved environment, say a VM with 128 MB reduce the working set size to it's minimum? 是否会在内存不足的环境中实例化该进程,比如一个128 MB的虚拟机将工作集大小减少到最小?

Any help or insight would be greatly appreciated. 任何帮助或见解将不胜感激。

There is a good essay on this by Mark Russinovich. Mark Russinovich对此有一篇很好的文章

You can manually reduce your app's working set by using the Win32 API call SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1). 您可以使用Win32 API调用SetProcessWorkingSetSize(GetCurrentProcess(), - 1,-1)手动减少应用程序的工作集。 This is what Windows will do anyway when the system runs low on memory, but controlling when this happens yourself lets you strip your .NET app's working set to its minimum size for investigation purposes. 这是Windows在内存运行不足时会做的事情,但是控制何时发生这种情况会让你将.NET应用程序的工作集剥离到最小尺寸以便进行调查。

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

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