release memory periodically

This commit is contained in:
clowwindy
2014-11-18 21:55:45 +08:00
parent 919f9b5ce3
commit 09ad2ca272
5 changed files with 55 additions and 3 deletions
@@ -14,6 +14,8 @@ namespace Shadowsocks.Controller
// manipulates UI
// interacts with low level logic
private Thread _ramThread;
private Local local;
private PACServer pacServer;
private Configuration _config;
@@ -58,6 +60,7 @@ namespace Shadowsocks.Controller
}
UpdateSystemProxy();
StartReleasingMemory();
}
public Server GetCurrentServer()
@@ -161,6 +164,8 @@ namespace Shadowsocks.Controller
{
ConfigChanged(this, new EventArgs());
}
Util.Util.ReleaseMemory();
}
@@ -180,5 +185,21 @@ namespace Shadowsocks.Controller
{
UpdateSystemProxy();
}
private void StartReleasingMemory()
{
_ramThread = new Thread(new ThreadStart(ReleaseMemory));
_ramThread.IsBackground = true;
_ramThread.Start();
}
private void ReleaseMemory()
{
while (true)
{
Util.Util.ReleaseMemory();
Thread.Sleep(30 * 1000);
}
}
}
}