本文介绍了这是真的,在.NET中的垃圾回收器被调用时,程序最小化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创造了在C#程序。该方案使用了大约60-70 NBSP;我的记忆MB。但是,当我最小化的程序,它需要较少的内存,也就是只有10  MB

I had created a program in C#. That program used about 60-70 MB of my memory.But when I minimized that program, it required less memory, that is, just 10 MB.

当我最大化或回来到该程序是用于20 NBSP; MB ...

When I maximized or came back to that program it used 20 MB...

为什么会出现这种情况?

Why does this happen?

这是真的,垃圾回收器被调用时,最大限度地减少了编程'?

Is it true that garbage collector gets called when you minimize the progam?

推荐答案

本文章解释了所有:的

This article explains all:THE MEMORY MYSTERY

这是从上面的网站上摘录:

this is an extract from the above site:

净都市传奇

有可能减少的净Windows窗体的工作集大小  应用程序通过最小化,然后最大化应用程序  后立即加载。 Windows操作系统修剪的工作集  他们最小化时应用。这是简单使用的内存  在加载前面提到的所有这些组件被修整  最小化和最大化应用程序的过程。您可以  通过创建和运行表现出这种行为给自己  Windows窗体应用程序,只需Form1并没有增加code。

      
  1. 创建和运行简单的应用程序。

  1. Create and run the simple application.

打开Windows任务管理器,然后它的进程选项卡。你会看到任务管理器显示应用程序的内存使用情况,在约  12.5 MB。

Open the Windows Task Manager and then its Processes Tab. You will see the Task Manager shows your application’s memory usage at approx. 12.5 MB.

现在减少你的应用程序,然后将其最大化。再次检查任务管理器。你会看到任务管理器现在显示出您  应用程序的内存使用情况大约1.5 MB。所使用的存储器  加载,当你的应用程序的启动被开垦利用集会  当你最小化的应用程序内存管理。

Now minimize your application and then maximize it. Check the Task Manager again. You will see the Task Manager now shows your application’s memory usage at approx. 1.5 MB. The memory that was used to load assemblies when your application was launched was reclaimed by memory management when you minimized the application.

你通过最小化改进内存管理或应用程序的性能和  最大限度地提高你的应用程序?号你可以找到一些净视窗  程序员谁加code,尽量减少然后最大化他们的节目  以为他们是优化内存。由于这些程序员  分享此技术与他人一种净都市传奇一直  出生 - 基于虚构不是事实的编程习惯。本  做法是不必要的,因为当操作系统需要的未使用的内存离开  当加载的程序集的背后,将回收它  自动。事实上,减少了应用程序的大小  当内存充足可能会降低性能的工作集。

Did you improve memory management or application performance by minimizing and maximizing your application? No. You can find some .Net Windows programmers who add code to minimize and then maximize their programs thinking that they are optimizing memory. As these programmers have shared this technique with others a sort of .Net Urban Legend has been born – a programming practice based on fiction not fact. This practice is unnecessary because when OS needs the unused memory left behind when the assemblies were loaded it will reclaim it automatically. In fact, decreasing the size of your application’s working set when memory is plentiful may decrease performance.

这篇关于这是真的,在.NET中的垃圾回收器被调用时,程序最小化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 06:03