.NET ez 2012-06-04
.NET 程式必需載入 .NET Framework ,所以記憶體用量至少5MB以上
其實可以透過 SetProcessWorkingSetSize API 來達到記憶體壓縮的效果 以下為程式碼範例:
using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Forms; namespace Test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //引用API [DllImport("kernel32.dll")] static extern Boolean SetProcessWorkingSetSize(IntPtr procHandle, Int32 min, Int32 max); private void button1_Click(object sender, EventArgs e) { //壓縮記憶體 SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); } } }
標籤: .NET