"你好!世界"在.NET 4中产生3500页错误你好、错误、世界、QUOT

2023-09-03 05:45:58 作者:心软是最致命的脆弱

我运行Windows Vista和Visual Studio 2010,使用.NET 4中。 2 GB的RAM和800 MB可用。

I'm running Windows Vista and Visual Studio 2010, using .Net 4. 2 GB of RAM and about 800 MB free.

我创建一个Windows窗体应用程序并添加任何code到它。只要编译发布模式,关闭Visual Studio和启动应用程序。如果我看在任务管理器应用程序生成的3500页错误刚刚开始,什么都不做。

I create a Windows Form application and add no code to it. Just compile it in release mode, close Visual Studio and start the application. If I look in task manager the application generated 3500 page faults for just starting and doing nothing.

如果我创建一个控制台应用程序,只需添加到Console.ReadLine(); 来保持它打开它产生1500页错误

If I create a console application and just add a Console.ReadLine(); to keep it open it generates 1500 page faults.

时的净是正常的行为?这些数字似乎高得离谱了我。

Is that normal behaviour for .Net? These numbers seem ridiculously high to me.

推荐答案

您要明白,还有更多的code到.NET应用程序不仅仅是code,你写的。它具有加载程序集,分析它,编译它,执行它,然后加载各种支持库等。(其中一些可能需要类似的解析,compliling等)所有这些事情产生页面错误。 3500是不是在事物的宏伟计划,很多页面错误。

You have to understand that there's more code to a .net application than just the code you wrote. It has to load the assembly, parse it, compile it, execute it, then load in various support libraries, etc.. (some of which may require similar parsing, compliling, etc..) all of those things create page faults. 3500 is not that many page faults in the grand scheme of things.

作为一个例子,我尝试了一些简单的控制台应用程序。更,从控制台上运行,产生750页错误,而这是一个pretty的微小应用程序,并比从一个输入到另一回声更小。它是用C语言编写,未垃圾回收一个lanugage,没有一个虚拟机,或者一个大的运行时库,有来与它(它是静态链接,所以它不依赖于运行时)。

As an example, I tried out a few "simple" console apps. More, run from a console, generates 750 page faults, and this is a pretty tiny app that does little more than echo from one input to the other. It's written in C, a lanugage that is not garbage collected, doesn't have a virtual machine, or a big runtime library that has to come with it (it's statically linked, so it's not depending on a runtime).

由于所有的.NET确实,单行控制台应用程序,只是没有只使用1500页故障一的ReadLine似乎相当不错。

Given all that .NET does, a single line console app that just does a ReadLine using only 1500 page faults seems quite good.

我什至不知道你为什么在乎页面错误。也许你正从一个平台,未来在哪里页面错误是一件坏事。在Windows中,过程页支持的,这意味着,在OS的存储器映射的可执行文件,并据此要求加载页面根据需要(这包括共享库,以及可执行文件本身,图标,图像,各种事情)。其中每一个页面生成页面错误,当操作系统需要将其加载到内存中。这是正常的,这是操作系统的工作方式。

I'm not even sure why you care about page faults. Perhaps you are coming from a platform where page faults are a bad thing. In Windows, processes are "page backed", which means that the OS memory maps an executable, and then demand loads pages as needed (this includes shared libraries, as well as the executable itself, icons, images, all kinds of things). Each of those pages generate a page fault when the OS needs to load them into memory. That's normal, and that's the way the OS works.

 
精彩推荐
图片推荐