this is MemoryCompressor, i found this in my old source that i was using very long time ago.
here it is.
Code:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace COServer
{
public class MemoryCompressor
{
internal class Native
{
// API Windows
[DllImport("kernel32")]
public static extern IntPtr OpenProcess(UInt32 dwAccess, Int32 dwDesiredAccess, UInt32 dwPID);
[DllImport("psapi")]
public static extern Int32 EmptyWorkingSet(IntPtr dwObject);
[DllImport("kernel32")]
public static extern Int32 CloseHandle(IntPtr dwObject);
internal static unsafe void memcpy(byte* buffer, byte* ptr, int p)
{
throw new NotImplementedException();
}
}
private uint m_ProcessId = 0;
public MemoryCompressor()
{
m_ProcessId = (uint)Process.GetCurrentProcess().Id;
}
public void Optimize()
{
if (m_ProcessId != 0)
{
IntPtr Handle = Native.OpenProcess((uint)0x1F0FFF, 1, m_ProcessId);
Native.EmptyWorkingSet(Handle);
Native.CloseHandle(Handle);
}
else
throw new Exception("MeomoryCompressor::Optimize() -> The process Id can't be equal to zero!");
}
public void Close()
{
m_ProcessId = 0;
}
}
this might not work with you or dont help allot, but it helped me allot for sure,
NOTE: i was reading on google today that MemoryCompressor might not be a good idea sometimes to use it on project like this, they might hurt the server but i dont know if that it fully true, so yah.
edit (1:11Am 2/3/2013)
they told me that this is not a good way,
#request close, but if you still need this feel free to take it maybe you can make something better out of it.






