mirror of
https://github.com/greenshot/greenshot
synced 2025-07-13 08:33:53 -07:00
Added lower memory footprint expert setting and created a PsAPI.cs file for the Process API invokes.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1866 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
ffb9502015
commit
d0ff4fbed6
8 changed files with 95 additions and 41 deletions
|
@ -1179,6 +1179,10 @@ namespace Greenshot {
|
|||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BackgroundWorkerTimerTick(object sender, EventArgs e) {
|
||||
if (conf.MinimizeWorkingSetSize) {
|
||||
LOG.Info("Calling EmptyWorkingSet");
|
||||
PsAPI.EmptyWorkingSet(Process.GetCurrentProcess().Handle);
|
||||
}
|
||||
if (UpdateHelper.IsUpdateCheckNeeded()) {
|
||||
LOG.Debug("BackgroundWorkerTimerTick checking for update");
|
||||
// Start update check in the background
|
||||
|
|
51
Greenshot/Forms/SettingsForm.Designer.cs
generated
51
Greenshot/Forms/SettingsForm.Designer.cs
generated
|
@ -73,7 +73,7 @@ namespace Greenshot {
|
|||
this.groupbox_destination = new GreenshotPlugin.Controls.GreenshotGroupBox();
|
||||
this.checkbox_picker = new GreenshotPlugin.Controls.GreenshotCheckBox();
|
||||
this.listview_destinations = new System.Windows.Forms.ListView();
|
||||
this.destination = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.destination = new System.Windows.Forms.ColumnHeader();
|
||||
this.tabcontrol = new System.Windows.Forms.TabControl();
|
||||
this.tab_general = new GreenshotPlugin.Controls.GreenshotTabPage();
|
||||
this.groupbox_network = new GreenshotPlugin.Controls.GreenshotGroupBox();
|
||||
|
@ -124,6 +124,7 @@ namespace Greenshot {
|
|||
this.button_pluginconfigure = new GreenshotPlugin.Controls.GreenshotButton();
|
||||
this.tab_expert = new GreenshotPlugin.Controls.GreenshotTabPage();
|
||||
this.groupbox_expert = new GreenshotPlugin.Controls.GreenshotGroupBox();
|
||||
this.checkbox_checkunstableupdates = new GreenshotPlugin.Controls.GreenshotCheckBox();
|
||||
this.checkbox_suppresssavedialogatclose = new GreenshotPlugin.Controls.GreenshotCheckBox();
|
||||
this.label_counter = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||
this.textbox_counter = new GreenshotPlugin.Controls.GreenshotTextBox();
|
||||
|
@ -135,8 +136,8 @@ namespace Greenshot {
|
|||
this.label_clipboardformats = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||
this.checkbox_enableexpert = new GreenshotPlugin.Controls.GreenshotCheckBox();
|
||||
this.listview_clipboardformats = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.checkbox_checkunstableupdates = new GreenshotPlugin.Controls.GreenshotCheckBox();
|
||||
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
this.checkbox_minimizememoryfootprint = new GreenshotPlugin.Controls.GreenshotCheckBox();
|
||||
this.groupbox_preferredfilesettings.SuspendLayout();
|
||||
this.groupbox_applicationsettings.SuspendLayout();
|
||||
this.groupbox_qualitysettings.SuspendLayout();
|
||||
|
@ -1038,6 +1039,7 @@ namespace Greenshot {
|
|||
//
|
||||
// groupbox_expert
|
||||
//
|
||||
this.groupbox_expert.Controls.Add(this.checkbox_minimizememoryfootprint);
|
||||
this.groupbox_expert.Controls.Add(this.checkbox_checkunstableupdates);
|
||||
this.groupbox_expert.Controls.Add(this.checkbox_suppresssavedialogatclose);
|
||||
this.groupbox_expert.Controls.Add(this.label_counter);
|
||||
|
@ -1058,10 +1060,20 @@ namespace Greenshot {
|
|||
this.groupbox_expert.TabStop = false;
|
||||
this.groupbox_expert.Text = "Expert";
|
||||
//
|
||||
// checkbox_checkunstableupdates
|
||||
//
|
||||
this.checkbox_checkunstableupdates.LanguageKey = "expertsettings_checkunstableupdates";
|
||||
this.checkbox_checkunstableupdates.Location = new System.Drawing.Point(10, 191);
|
||||
this.checkbox_checkunstableupdates.Name = "checkbox_checkunstableupdates";
|
||||
this.checkbox_checkunstableupdates.PropertyName = "CheckUnstable";
|
||||
this.checkbox_checkunstableupdates.Size = new System.Drawing.Size(394, 19);
|
||||
this.checkbox_checkunstableupdates.TabIndex = 29;
|
||||
this.checkbox_checkunstableupdates.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkbox_suppresssavedialogatclose
|
||||
//
|
||||
this.checkbox_suppresssavedialogatclose.LanguageKey = "expertsettings_suppresssavedialogatclose";
|
||||
this.checkbox_suppresssavedialogatclose.Location = new System.Drawing.Point(10, 182);
|
||||
this.checkbox_suppresssavedialogatclose.Location = new System.Drawing.Point(10, 168);
|
||||
this.checkbox_suppresssavedialogatclose.Name = "checkbox_suppresssavedialogatclose";
|
||||
this.checkbox_suppresssavedialogatclose.PropertyName = "SuppressSaveDialogAtClose";
|
||||
this.checkbox_suppresssavedialogatclose.SectionName = "Editor";
|
||||
|
@ -1108,7 +1120,7 @@ namespace Greenshot {
|
|||
// checkbox_thumbnailpreview
|
||||
//
|
||||
this.checkbox_thumbnailpreview.LanguageKey = "expertsettings_thumbnailpreview";
|
||||
this.checkbox_thumbnailpreview.Location = new System.Drawing.Point(10, 163);
|
||||
this.checkbox_thumbnailpreview.Location = new System.Drawing.Point(10, 149);
|
||||
this.checkbox_thumbnailpreview.Name = "checkbox_thumbnailpreview";
|
||||
this.checkbox_thumbnailpreview.PropertyName = "ThumnailPreview";
|
||||
this.checkbox_thumbnailpreview.Size = new System.Drawing.Size(394, 24);
|
||||
|
@ -1119,7 +1131,7 @@ namespace Greenshot {
|
|||
// checkbox_optimizeforrdp
|
||||
//
|
||||
this.checkbox_optimizeforrdp.LanguageKey = "expertsettings_optimizeforrdp";
|
||||
this.checkbox_optimizeforrdp.Location = new System.Drawing.Point(10, 144);
|
||||
this.checkbox_optimizeforrdp.Location = new System.Drawing.Point(10, 130);
|
||||
this.checkbox_optimizeforrdp.Name = "checkbox_optimizeforrdp";
|
||||
this.checkbox_optimizeforrdp.PropertyName = "OptimizeForRDP";
|
||||
this.checkbox_optimizeforrdp.Size = new System.Drawing.Size(394, 24);
|
||||
|
@ -1130,7 +1142,7 @@ namespace Greenshot {
|
|||
// checkbox_autoreducecolors
|
||||
//
|
||||
this.checkbox_autoreducecolors.LanguageKey = "expertsettings_autoreducecolors";
|
||||
this.checkbox_autoreducecolors.Location = new System.Drawing.Point(10, 125);
|
||||
this.checkbox_autoreducecolors.Location = new System.Drawing.Point(10, 111);
|
||||
this.checkbox_autoreducecolors.Name = "checkbox_autoreducecolors";
|
||||
this.checkbox_autoreducecolors.PropertyName = "OutputFileAutoReduceColors";
|
||||
this.checkbox_autoreducecolors.Size = new System.Drawing.Size(394, 24);
|
||||
|
@ -1142,7 +1154,7 @@ namespace Greenshot {
|
|||
//
|
||||
this.label_clipboardformats.AutoSize = true;
|
||||
this.label_clipboardformats.LanguageKey = "expertsettings_clipboardformats";
|
||||
this.label_clipboardformats.Location = new System.Drawing.Point(7, 45);
|
||||
this.label_clipboardformats.Location = new System.Drawing.Point(7, 39);
|
||||
this.label_clipboardformats.Name = "label_clipboardformats";
|
||||
this.label_clipboardformats.Size = new System.Drawing.Size(88, 13);
|
||||
this.label_clipboardformats.TabIndex = 20;
|
||||
|
@ -1168,10 +1180,10 @@ namespace Greenshot {
|
|||
this.columnHeader1});
|
||||
this.listview_clipboardformats.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.listview_clipboardformats.LabelWrap = false;
|
||||
this.listview_clipboardformats.Location = new System.Drawing.Point(109, 44);
|
||||
this.listview_clipboardformats.Location = new System.Drawing.Point(109, 38);
|
||||
this.listview_clipboardformats.Name = "listview_clipboardformats";
|
||||
this.listview_clipboardformats.ShowGroups = false;
|
||||
this.listview_clipboardformats.Size = new System.Drawing.Size(291, 80);
|
||||
this.listview_clipboardformats.Size = new System.Drawing.Size(291, 72);
|
||||
this.listview_clipboardformats.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.listview_clipboardformats.TabIndex = 0;
|
||||
this.listview_clipboardformats.UseCompatibleStateImageBehavior = false;
|
||||
|
@ -1182,15 +1194,15 @@ namespace Greenshot {
|
|||
this.columnHeader1.Text = "Destination";
|
||||
this.columnHeader1.Width = 280;
|
||||
//
|
||||
// checkbox_checkunstableupdates
|
||||
// checkbox_minimizememoryfootprint
|
||||
//
|
||||
this.checkbox_checkunstableupdates.LanguageKey = "expertsettings_checkunstableupdates";
|
||||
this.checkbox_checkunstableupdates.Location = new System.Drawing.Point(10, 201);
|
||||
this.checkbox_checkunstableupdates.Name = "checkbox_checkunstableupdates";
|
||||
this.checkbox_checkunstableupdates.PropertyName = "CheckUnstable";
|
||||
this.checkbox_checkunstableupdates.Size = new System.Drawing.Size(394, 24);
|
||||
this.checkbox_checkunstableupdates.TabIndex = 29;
|
||||
this.checkbox_checkunstableupdates.UseVisualStyleBackColor = true;
|
||||
this.checkbox_minimizememoryfootprint.LanguageKey = "expertsettings_minimizememoryfootprint";
|
||||
this.checkbox_minimizememoryfootprint.Location = new System.Drawing.Point(10, 211);
|
||||
this.checkbox_minimizememoryfootprint.Name = "checkbox_minimizememoryfootprint";
|
||||
this.checkbox_minimizememoryfootprint.PropertyName = "MinimizeWorkingSetSize";
|
||||
this.checkbox_minimizememoryfootprint.Size = new System.Drawing.Size(394, 19);
|
||||
this.checkbox_minimizememoryfootprint.TabIndex = 30;
|
||||
this.checkbox_minimizememoryfootprint.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
|
@ -1205,7 +1217,6 @@ namespace Greenshot {
|
|||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SettingsForm";
|
||||
this.Text = "Settings";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SettingsFormFormClosing);
|
||||
this.Shown += new System.EventHandler(this.SettingsFormShown);
|
||||
this.groupbox_preferredfilesettings.ResumeLayout(false);
|
||||
|
@ -1239,8 +1250,8 @@ namespace Greenshot {
|
|||
this.groupbox_expert.ResumeLayout(false);
|
||||
this.groupbox_expert.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_minimizememoryfootprint;
|
||||
private System.Windows.Forms.ColumnHeader destination;
|
||||
private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_picker;
|
||||
private System.Windows.Forms.ListView listview_destinations;
|
||||
|
|
|
@ -488,6 +488,7 @@ namespace Greenshot {
|
|||
textbox_counter.Enabled = state;
|
||||
checkbox_suppresssavedialogatclose.Enabled = state;
|
||||
checkbox_checkunstableupdates.Enabled = state;
|
||||
checkbox_minimizememoryfootprint.Enabled = state;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -673,6 +673,9 @@ time, e.g. 11_58_32 (plus extension defined in the settings)
|
|||
<resource name="expertsettings_suppresssavedialogatclose">
|
||||
Suppress the save dialog when closing the editor
|
||||
</resource>
|
||||
<resource name="expertsettings_minimizememoryfootprint">
|
||||
Minimize memory footprint, but with a performance penalty (not adviced).
|
||||
</resource>
|
||||
<resource name="WindowCaptureMode.Screen">
|
||||
As displayed
|
||||
</resource>
|
||||
|
|
|
@ -171,6 +171,8 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
[IniProperty("OptimizeForRDP", Description="Make some optimizations for usage with remote desktop", DefaultValue="False")]
|
||||
public bool OptimizeForRDP;
|
||||
[IniProperty("MinimizeWorkingSetSize", Description="Optimize memory footprint, but with a performance penalty!", DefaultValue="False")]
|
||||
public bool MinimizeWorkingSetSize;
|
||||
|
||||
|
||||
// change to false for releases
|
||||
|
|
|
@ -265,6 +265,7 @@
|
|||
<Compile Include="UnmanagedHelpers\Enumerations.cs" />
|
||||
<Compile Include="UnmanagedHelpers\GDI32.cs" />
|
||||
<Compile Include="UnmanagedHelpers\Kernel32.cs" />
|
||||
<Compile Include="UnmanagedHelpers\PsAPI.cs" />
|
||||
<Compile Include="UnmanagedHelpers\Shell32.cs" />
|
||||
<Compile Include="UnmanagedHelpers\Structs.cs" />
|
||||
<Compile Include="UnmanagedHelpers\User32.cs" />
|
||||
|
|
|
@ -66,12 +66,6 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
[DllImport("kernel32", SetLastError = true)]
|
||||
public static extern bool CloseHandle(IntPtr hObject);
|
||||
|
||||
// TODO: Move to PSAPI.cs ??
|
||||
[DllImport("psapi", SetLastError = true)]
|
||||
public static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, uint nSize);
|
||||
[DllImport("psapi", SetLastError = true)]
|
||||
public static extern uint GetProcessImageFileName(IntPtr hProcess, StringBuilder lpImageFileName, uint nSize);
|
||||
|
||||
/// <summary>
|
||||
/// Method to get the process path
|
||||
/// </summary>
|
||||
|
@ -85,7 +79,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
IntPtr hprocess = Kernel32.OpenProcess(ProcessAccessFlags.QueryInformation | ProcessAccessFlags.VMRead, false, processid);
|
||||
if (hprocess != IntPtr.Zero) {
|
||||
try {
|
||||
if (Kernel32.GetModuleFileNameEx(hprocess, IntPtr.Zero, _PathBuffer, (uint)_PathBuffer.Capacity) > 0) {
|
||||
if (PsAPI.GetModuleFileNameEx(hprocess, IntPtr.Zero, _PathBuffer, (uint)_PathBuffer.Capacity) > 0) {
|
||||
return _PathBuffer.ToString();
|
||||
}
|
||||
} finally {
|
||||
|
@ -103,7 +97,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
}
|
||||
|
||||
// Try the GetProcessImageFileName method
|
||||
if (Kernel32.GetProcessImageFileName(hprocess, _PathBuffer, (uint)_PathBuffer.Capacity) > 0) {
|
||||
if (PsAPI.GetProcessImageFileName(hprocess, _PathBuffer, (uint)_PathBuffer.Capacity) > 0) {
|
||||
string dospath = _PathBuffer.ToString();
|
||||
foreach (string drive in Environment.GetLogicalDrives()) {
|
||||
if (Kernel32.QueryDosDevice(drive.TrimEnd('\\'), _PathBuffer, (uint)_PathBuffer.Capacity) > 0) {
|
||||
|
|
38
GreenshotPlugin/UnmanagedHelpers/PsAPI.cs
Normal file
38
GreenshotPlugin/UnmanagedHelpers/PsAPI.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace GreenshotPlugin.UnmanagedHelpers {
|
||||
/// <summary>
|
||||
/// Description of PsAPI.
|
||||
/// </summary>
|
||||
public class PsAPI {
|
||||
[DllImport("psapi", SetLastError = true)]
|
||||
public static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, uint nSize);
|
||||
[DllImport("psapi", SetLastError = true)]
|
||||
public static extern uint GetProcessImageFileName(IntPtr hProcess, StringBuilder lpImageFileName, uint nSize);
|
||||
[DllImport("psapi")]
|
||||
public static extern int EmptyWorkingSet(IntPtr hwProc);
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue