Register for your free account! | Forgot your password?

You last visited: Today at 01:03

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



MemoryCompressor

Discussion on MemoryCompressor within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
LordGragen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 606
Received Thanks: 68
MemoryCompressor

hey guys, so today i am going to share something with you guys that i thow it might be helpful,

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;
        }
    }
} #credit "i dont know his name but credit to who ever made it"


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.
LordGragen. is offline  
Thanks
1 User
Old 02/03/2013, 15:52   #2


 
CptSky's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
I made this thing based on an AutoIt application. Although it works, it should never be used with a program that requires high efficiency as a server.

Also, as a side note, the psapi dll no longer contains the required function which has been moved in kernel32 since Vista.

Btw. I never though it would surface
CptSky is offline  
Thanks
1 User
Old 04/10/2013, 16:51   #3
 
marcbacor6666's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 557
Received Thanks: 76
can u remake it and make it work in any 5535+ public source?
marcbacor6666 is offline  
Old 04/11/2013, 09:20   #4
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
Quote:
Originally Posted by marcbacor6666 View Post
can u remake it and make it work in any 5535+ public source?
.... The code snippet above is universal ... for absolutely any process ever created in a modern Windows machine. Don't be lame, read the 5 lines of code. There are absolutely no excuses because you can even google each line and figure out what this does.

PS: You shouldn't even be using this code. You didn't read what CptSky said about it either. Read, it helps .
Spirited is offline  
Old 04/11/2013, 17:23   #5
 
marcbacor6666's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 557
Received Thanks: 76
ok ^^
marcbacor6666 is offline  
Old 04/12/2013, 18:57   #6
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Quote:
Originally Posted by CptSky View Post
I made this thing based on an AutoIt application. Although it works, it should never be used with a program that requires high efficiency as a server.
WHY ?
shadowman123 is offline  
Old 04/12/2013, 19:20   #7
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
Quote:
Originally Posted by shadowman123 View Post
WHY ?
Read this:
Super Aids is offline  
Old 04/12/2013, 20:26   #8
 
littlechris95's Avatar
 
elite*gold: 0
Join Date: Nov 2011
Posts: 150
Received Thanks: 11
It was nothing to do and did a program based on this code.



Download Link:
littlechris95 is offline  
Reply




All times are GMT +1. The time now is 01:04.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.