Testing what happens if Greenshot uses EmptyWorkingSet after start-up.

This commit is contained in:
RKrom 2014-06-16 23:14:37 +02:00
commit 9cc485243f

View file

@ -407,6 +407,8 @@ namespace Greenshot {
if (dataTransport != null) { if (dataTransport != null) {
HandleDataTransport(dataTransport); HandleDataTransport(dataTransport);
} }
// Make Greenshot use less memory after startup
EmptyWorkingSet();
} }
/// <summary> /// <summary>
@ -1038,6 +1040,13 @@ namespace Greenshot {
Exit(); Exit();
} }
private void CheckStateChangedHandler(object sender, EventArgs e) {
ToolStripMenuSelectListItem captureMouseItem = sender as ToolStripMenuSelectListItem;
if (captureMouseItem != null) {
_conf.CaptureMousepointer = captureMouseItem.Checked;
}
}
/// <summary> /// <summary>
/// This needs to be called to initialize the quick settings menu entries /// This needs to be called to initialize the quick settings menu entries
/// </summary> /// </summary>
@ -1055,9 +1064,7 @@ namespace Greenshot {
captureMouseItem.Text = Language.GetString("settings_capture_mousepointer"); captureMouseItem.Text = Language.GetString("settings_capture_mousepointer");
captureMouseItem.Checked = _conf.CaptureMousepointer; captureMouseItem.Checked = _conf.CaptureMousepointer;
captureMouseItem.CheckOnClick = true; captureMouseItem.CheckOnClick = true;
captureMouseItem.CheckStateChanged += delegate { captureMouseItem.CheckStateChanged += CheckStateChangedHandler;
_conf.CaptureMousepointer = captureMouseItem.Checked;
};
contextmenu_quicksettings.DropDownItems.Add(captureMouseItem); contextmenu_quicksettings.DropDownItems.Add(captureMouseItem);
} }
@ -1372,6 +1379,15 @@ namespace Greenshot {
} }
} }
/// <summary>
/// Make the process use less memory by emptying the working set
/// </summary>
private void EmptyWorkingSet() {
using (Process currentProcess = Process.GetCurrentProcess()) {
PsAPI.EmptyWorkingSet(currentProcess.Handle);
}
}
/// <summary> /// <summary>
/// Do work in the background /// Do work in the background
/// </summary> /// </summary>
@ -1380,9 +1396,7 @@ namespace Greenshot {
private void BackgroundWorkerTimerTick(object sender, EventArgs e) { private void BackgroundWorkerTimerTick(object sender, EventArgs e) {
if (_conf.MinimizeWorkingSetSize) { if (_conf.MinimizeWorkingSetSize) {
LOG.Info("Calling EmptyWorkingSet"); LOG.Info("Calling EmptyWorkingSet");
using (Process currentProcess = Process.GetCurrentProcess()) { EmptyWorkingSet();
PsAPI.EmptyWorkingSet(currentProcess.Handle);
}
} }
if (UpdateHelper.IsUpdateCheckNeeded()) { if (UpdateHelper.IsUpdateCheckNeeded()) {
LOG.Debug("BackgroundWorkerTimerTick checking for update"); LOG.Debug("BackgroundWorkerTimerTick checking for update");