mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Usage of EmptyWorkingSet now via the configuration, so we don't use it for all people.
This commit is contained in:
parent
9cc485243f
commit
9aefc90460
3 changed files with 22 additions and 14 deletions
|
@ -19,20 +19,32 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
|
||||
namespace GreenshotPlugin.UnmanagedHelpers {
|
||||
/// <summary>
|
||||
/// Description of PsAPI.
|
||||
/// </summary>
|
||||
public class PsAPI {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(PsAPI));
|
||||
[DllImport("psapi", SetLastError = true, CharSet=CharSet.Unicode)]
|
||||
public static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, uint nSize);
|
||||
[DllImport("psapi", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern uint GetProcessImageFileName(IntPtr hProcess, StringBuilder lpImageFileName, uint nSize);
|
||||
[DllImport("psapi")]
|
||||
public static extern int EmptyWorkingSet(IntPtr hwProc);
|
||||
private static extern int EmptyWorkingSet(IntPtr hwProc);
|
||||
|
||||
/// <summary>
|
||||
/// Make the process use less memory by emptying the working set
|
||||
/// </summary>
|
||||
public static void EmptyWorkingSet() {
|
||||
LOG.Info("Calling EmptyWorkingSet");
|
||||
using (Process currentProcess = Process.GetCurrentProcess()) {
|
||||
EmptyWorkingSet(currentProcess.Handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue