Posts: 1,121
Threads: 139
Joined: Nov 2009
Reputation:
0
Hi, my server has been using alot of CPU, it's a download and i'm searching for problems to fix that might be causing it.
I heard loops can be a cause, or a leak? what do they mean by that? Can someone give me an example of a bad loop? or not in use loop, or just bad things that could be causing this.
Posts: 1,047
Threads: 23
Joined: Jun 2009
If you take a loop you can see maybe some unlimited loops? I have managed to let sa-mp use 2 gb of ram, then my pc crashed.
Posts: 721
Threads: 25
Joined: Nov 2007
Reputation:
0
That basically loops through 500players 18 times. Whether it's healthy/unhealthy as to CPU&RAM usage depends on what you're checking.
Let's say, you're getting the name of a player, and adding [PK] infront of their name.
You're checking "MAX_PLAYERS" which is 500. That means: You're checking 500 player names, and after that: you're adding 4 characters [(1) P(2) K(3) ](4). You're doing that 18 times.
Posts: 2,857
Threads: 62
Joined: Dec 2010
Reputation:
0
Remember to re-define your MAX_PLAYERS if you have under 500 maxplayers! This is why you shouldn't set your player limit to high.
Posts: 3,793
Threads: 196
Joined: Jan 2010
Reputation:
0
Why not use GetMaxPlayers()
?
I mean loop through your whole server slots not 500 player slots it self.
Maybe using foreach COULD (IDK) COULD help.
Posts: 6,129
Threads: 36
Joined: Jan 2009
You should read ******' thread on 'code optimisations' to gain an accurate understanding of what might be causing this error for you. Infinite loops might not be your problem, there are many factors to consider adjusting when it comes to optimisation. Click
here for a link to said thread.
Posts: 1,121
Threads: 139
Joined: Nov 2009
Reputation:
0
Thanks guys, we've managed to reduce the CPU usage with some help here, but theres an even worst problem now.
The CPU may be okay, but the RAM is still increasing, any possibilities of what could be causing the RAM to increase?
Thanks
Posts: 1,297
Threads: 17
Joined: Apr 2011
Use Gamebooster and it will help you for the ram usage