Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to keep your Server Memory low[Not my idea]
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?
#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?
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: 

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.
new string[1024];
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.

Messages In This Thread
How to keep your Server Memory low[Not my idea] - by alterego - 12-17-2016, 09:13 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb SA-MP Most common problems fix <server/> Youssef 7 8,359 05-11-2024, 04:24 PM
Last Post: beautifulhome
  File Manager Arrangement(Not all my idea) alterego 10 24,156 04-19-2017, 07:17 PM
Last Post: joker123

Forum Jump:

Users browsing this thread: 1 Guest(s)