1. <small id='3HYM7'></small><noframes id='3HYM7'>

    <i id='3HYM7'><tr id='3HYM7'><dt id='3HYM7'><q id='3HYM7'><span id='3HYM7'><b id='3HYM7'><form id='3HYM7'><ins id='3HYM7'></ins><ul id='3HYM7'></ul><sub id='3HYM7'></sub></form><legend id='3HYM7'></legend><bdo id='3HYM7'><pre id='3HYM7'><center id='3HYM7'></center></pre></bdo></b><th id='3HYM7'></th></span></q></dt></tr></i><div id='3HYM7'><tfoot id='3HYM7'></tfoot><dl id='3HYM7'><fieldset id='3HYM7'></fieldset></dl></div>
      • <bdo id='3HYM7'></bdo><ul id='3HYM7'></ul>
      <tfoot id='3HYM7'></tfoot>
      <legend id='3HYM7'><style id='3HYM7'><dir id='3HYM7'><q id='3HYM7'></q></dir></style></legend>
    1. 在 .NET 中,当您最小化程序时会调用垃圾收集器,这是真的吗?

      时间:2023-09-13

      <small id='E9wy5'></small><noframes id='E9wy5'>

        <bdo id='E9wy5'></bdo><ul id='E9wy5'></ul>
          <tfoot id='E9wy5'></tfoot>
        1. <i id='E9wy5'><tr id='E9wy5'><dt id='E9wy5'><q id='E9wy5'><span id='E9wy5'><b id='E9wy5'><form id='E9wy5'><ins id='E9wy5'></ins><ul id='E9wy5'></ul><sub id='E9wy5'></sub></form><legend id='E9wy5'></legend><bdo id='E9wy5'><pre id='E9wy5'><center id='E9wy5'></center></pre></bdo></b><th id='E9wy5'></th></span></q></dt></tr></i><div id='E9wy5'><tfoot id='E9wy5'></tfoot><dl id='E9wy5'><fieldset id='E9wy5'></fieldset></dl></div>
          <legend id='E9wy5'><style id='E9wy5'><dir id='E9wy5'><q id='E9wy5'></q></dir></style></legend>
                  <tbody id='E9wy5'></tbody>
                本文介绍了在 .NET 中,当您最小化程序时会调用垃圾收集器,这是真的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我用 C# 创建了一个程序.该程序使用了我大约 60-70MB 的内存.但是当我最小化那个程序时,它需要更少的内存,即只有 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 MB...

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

                为什么会这样?

                当您最小化程序时是否会调用垃圾收集器?

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

                推荐答案

                本文一一讲解:记忆之谜

                这是来自上述网站的摘录:

                this is an extract from the above site:

                .Net Urban Legend

                可以减少 .Net Windows 窗体的工作集大小通过最小化然后最大化应用程序来应用程序加载后立即.Windows 操作系统修剪工作集当它们被最小化时的应用程序.短暂使用的内存在加载前面提到的所有这些程序集时,最小化和最大化应用程序的过程.你可以通过创建和运行仅包含 Form1 且未添加代码的 Windows 窗体应用程序.

                It is possible to reduce the working set size of a .Net Windows Forms application by minimizing and then maximizing the application immediately after it loads. Windows OS trims the working set of applications when they are minimized. The memory that was briefly used while loading all those assemblies mentioned earlier is trimmed by the process of minimizing and maximizing the application. You can demonstrate this behavior to yourself by creating and running a Windows Forms application with just Form1 and no added 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.

                您是否通过最小化和优化内存管理或应用程序性能?最大化您的应用程序?不,你可以找到一些 .Net Windows添加代码以最小化然后最大化他们的程序的程序员认为他们正在优化内存.正如这些程序员所拥有的与其他人分享了这种技术,一种 .Net Urban Legend 已经出生——一种基于虚构而非事实的编程实践.这实践是不必要的,因为当操作系统需要剩余未使用的内存时加载程序集后,它将回收它自动地.事实上,减小应用程序的大小内存充足时的工作集可能会降低性能.

                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 中,当您最小化程序时会调用垃圾收集器,这是真的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:静态成员的垃圾收集 下一篇:MVVM light Messenger 中的动作、局部变量和垃圾收集的奇怪行为

                相关文章

                    <bdo id='e6axK'></bdo><ul id='e6axK'></ul>

                  <i id='e6axK'><tr id='e6axK'><dt id='e6axK'><q id='e6axK'><span id='e6axK'><b id='e6axK'><form id='e6axK'><ins id='e6axK'></ins><ul id='e6axK'></ul><sub id='e6axK'></sub></form><legend id='e6axK'></legend><bdo id='e6axK'><pre id='e6axK'><center id='e6axK'></center></pre></bdo></b><th id='e6axK'></th></span></q></dt></tr></i><div id='e6axK'><tfoot id='e6axK'></tfoot><dl id='e6axK'><fieldset id='e6axK'></fieldset></dl></div>

                  <tfoot id='e6axK'></tfoot>
                    <legend id='e6axK'><style id='e6axK'><dir id='e6axK'><q id='e6axK'></q></dir></style></legend>

                    <small id='e6axK'></small><noframes id='e6axK'>