1

除了使用 Memory Streams 之外,我之前从未弄乱过内存。但我最近下载了一个“清除”内存的 RAM Cleaner。我很好奇它的工作原理和作用。我尝试在谷歌上搜索一些关于内存清理和清除的内容,但这对我来说并没有太大意义。内存清理是如何工作的?我在哪里可以了解更多信息?它是否对进程执行某种垃圾收集?

4

1 回答 1

2

也许这个 API 函数可以帮助你的朋友……这个函数对我来说非常有用,因为调用 EmptyWorkingSet/SetProcessWorkingSetSize 只是在操作系统执行它之前进行清理的一种方法。

我认为这是 C# 语法...转换并在 VB.net 中尝试:

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;

[DllImport("psapi.dll")]
public static extern bool EmptyWorkingSet(IntPtr hProcess);

    public void Clean()
    {
        // get handle to a process
        Process ThisProcess = Process.GetCurrentProcess();

        // empty as much as possible of its working set
        bool Result = EmptyWorkingSet(ThisProcess.Handle);

    }

ThisProcess.Handle 是您的程序的进程句柄。

也看看这个:MSDN Link

于 2013-04-19T15:40:59.340 回答