// Copyright 2005 by Omar Al Zabir. All rights are reserved.
//
// If you like this code then feel free to go ahead and use it.
// The only thing I ask is that you don't remove or alter my copyright notice.
//
// Your use of this software is entirely at your own risk. I make no claims or
// warrantees about the reliability or fitness of this code for any particular purpose.
// If you make changes or additions to this code please mark your code as being yours.
//
// website http://www.oazabir.com, email OmarAlZabir@gmail.com, msn oazabir@hotmail.com
using System;
namespace RSSFeeder.Helpers{
/// <summary>
/// Helps conserve memory
/// </summary>
public abstract class MemoryHelper
{
static bool m_TipAction;
static MemoryHelper()
{
m_TipAction = true;
}
public static void ReduceMemory()
{
try
{
System.Diagnostics.Debug.WriteLine("Reducing memory...");
System.Diagnostics.Process loProcess = System.Diagnostics.Process.GetCurrentProcess();
if(m_TipAction == true)
{
loProcess.MaxWorkingSet = (IntPtr)((int)loProcess.MaxWorkingSet - 1);
loProcess.MinWorkingSet = (IntPtr)((int)loProcess.MinWorkingSet - 1);
}
else
{
loProcess.MaxWorkingSet = (IntPtr)((int)loProcess.MaxWorkingSet + 1);
loProcess.MinWorkingSet = (IntPtr)((int)loProcess.MinWorkingSet + 1);
}
m_TipAction = !m_TipAction;
}
catch( Exception x )
{
System.Diagnostics.Debug.WriteLine( x );
}
}
}
}
|