ElitesHost Forums
How to keep your Server Memory low[Not my idea] - Printable Version

+- ElitesHost Forums (https://forum.eliteshost.com)
+-- Forum: Community (https://forum.eliteshost.com/forumdisplay.php?fid=5)
+--- Forum: Information & Guidelines (https://forum.eliteshost.com/forumdisplay.php?fid=16)
+---- Forum: Tutorials (https://forum.eliteshost.com/forumdisplay.php?fid=17)
+---- Thread: How to keep your Server Memory low[Not my idea] (/showthread.php?tid=41)

Pages: 1 2


How to keep your Server Memory low[Not my idea] - alterego - 12-17-2016

So people have asked question all over the internet about HAVING BIG MEMORY and that's a problem since it lags the players gaming experience and the more this memory gets bigger it gets lager and lager. 


So here are some easy simple tips you might have overlooked on your server.

Number 1:
Have you defined your #define MAX_(e.g MAX_PLAYERS, MAX_HOUSES, MAX_BUSINESSES to a realistic number?
Code:
#undef MAX_PLAYERS
#define MAX_PLAYERS 30 //Usually depends on your maximum server
On some research that I found and some experimenting that I did. I have tried defining and not defining the MAX_PLAYER and it gradually changed my memory usage and even .amx file size which is a problem. So I started to define MAX_PLAYERS on a hundred basis and it drastically changed my .amx and memory usage. So if you have a memory problem just define that MAX_PLAYERS and maybe that'll help your problem.
Number 2:
Keep you OnPlayerUpdate almost empty.
What do I mean?
Code:
public OnPlayerUpdate(playerid)
{
    if(playerTabbed[playerid] == 1)
    {
        playerTabbed[playerid] = 0;
        playerTabbedTime[playerid] = 0;
        if(GetPVarType(playerid, "tabbedVW") != 0) {
            SetPlayerVirtualWorld(playerid, GetPVarInt(playerid, "tabbedVW"));
            DeletePVar(playerid, "tabbedVW");
        }
    }
    playerSeconds[playerid] = gettime();
    if(GetPVarInt(playerid, "IsFrozen") == 1) TogglePlayerControllable(playerid, 0);

    new pCurWeap = GetPlayerWeapon(playerid);
   if(pCurWeap != pCurrentWeapon[playerid])
   {
       OnPlayerChangeWeapon(playerid, pCurWeap);
       pCurrentWeapon[playerid] = pCurWeap;
   }
    return 1;
}
that's what's inside my OnPlayerUpdate, since the cycle or what term do they use. Well in lay mans term the Cycle or loop the this public uses is pretty much in milliseconds or very fast. I will not indicate numbers since I really don't know how fast the cycle or loop goes but it makes your memory go up so high. Since it loads everything inside the OnPlayerUpdate in a millisecond cycle. Which is very dangerous for the memory. One thing is to keep that public empty or less occupied to lessen the load.
Number 3:
This is the best part.
people have told us about arrays and stuff. and do you understand what they're saying? No, mean either I'm no programmer at least but I know how to script by reading.
So arrays are simply a holder or such example is: 
Code:
string[128];

string holds 128 letters from your keyboard you go over that and string won't be able to read it. In lay mans explanation. A human being only have two hands. human[2]. If you get over that capacity of two human hands. A human will not be able to carry anymore because his two hands are used. Is that understandable?
Now let's get back to the array for memory usage.
Here are some codes. Try the difference between this two, compile them and see the difference.
Code:
new string[1024];
and
new string[128];
you will see a difference in the size of your .amx and the size of your memory but it might be small but small difference still make a difference.
So keep those arrays as small as possible and don't waste too much on it. If you need 20 letters then keep that 20 letters at bay. don't go higher than that coz it'll cost your server memory a burden.
Now if this have helped you on any occasion a thank you and a rep is only needed, and if you have more tips and tricks for the scripters out there then feel free to post them down there.
If you have any questions or violent reactions feel free to tell me, I might have said something wrong and edit it. I just want to help those who needs them.
Thanks for reading.


RE: How to keep your Server Memory low[Not my idea] - Pawno - 12-17-2016

Got'cha Nice Tutorial.. good for newbie.


RE: How to keep your Server Memory low[Not my idea] - KidPlaySamp - 12-17-2016

Niiiice it helps


RE: How to keep your Server Memory low[Not my idea] - ZuZu - 12-17-2016

Nice, is very useful.


RE: How to keep your Server Memory low[Not my idea] - alterego - 12-18-2016

Thanks...


RE: How to keep your Server Memory low[Not my idea] - ViRuS - 12-18-2016

Nice helpfull.. Thanks for help us.


RE: How to keep your Server Memory low[Not my idea] - Sentinel - 12-21-2016

Nice Tutorial!


RE: How to keep your Server Memory low[Not my idea] - rifat - 12-22-2016

Thank you i was finding this thanks for sharing


RE: How to keep your Server Memory low[Not my idea] - alterego - 12-23-2016

(12-22-2016, 04:38 PM)rifat Wrote: Thank you i was finding this thanks for sharing

It's good to know I can help people with stuffs Smile


RE: How to keep your Server Memory low[Not my idea] - Yaa - 01-10-2017

nice tuto