infinite loop? Causing high CPU usage
#1

G'day

Running my server, went to go in it today and it was down, logged into my host to get a message saying it has been automatically turned off due to high CPU usage... I asked them and they said
"discovered your server code has an infinite loop which is initiated as soon as the server is started. I would recommend checking any code/functions which are included OnGameModeInit and any recent plugins you added to your server."

Anyway it's originating from my streamer.pwn (I run my gamemode in separate parts)
I've been through all of it 3 times and can't see anything that would cause this.

So when the server is initiated, something in one of my gamemode parts (streamer(objects, pickups, text, etc)) does an infinite loop causing high CPU.

I highly doubt anyone will know an answer but yeah thanks
Reply
#2

check all while() and for(), also run it on your localhost to see what happens.
Reply
#3

Quote:

I highly doubt anyone will know an answer but yeah thanks

Of course, your sloppy code isn't our doings.

There won't be a precise answer without seeing the source code.
Reply
#4

Infinite loop? Wtf.

Do you see any?

for(;; ) (had to give space it turns it into a gawd dayum smiley)
??
Reply
#5

Test it on your local machine. Its possible that the streamer just takes a while to load all the objects, and the hoster stops this after a moment as it seems "infinite".

Alternatively, add a printf("some unique label", for_index); to all your loops and watch the output for a moment. Et voila! Youll see the label of the loop that does not stop.

Edit: Wow, this thread is old. Getting really silent in scripting discussion.
Reply
#6

I would check all of my control structures. (if, else, for, while, etc...) If it's happening as soon as the server initiates it will either be in a plugin, include or under OnGameModeInit. I would check all of the includes and plugins that are being used in that .pwn aswell.
Reply
#7

Run the profiler plugin by JernejL - That will be able to help identify what's causing the recursive calls.

You can also add checks to stop the loop if the interations exceed X value.
Reply
#8

Quote:
Originally Posted by KyleSmith
View Post
Run the profiler plugin by JernejL - That will be able to help identify what's causing the recursive calls.

You can also add checks to stop the loop if the interations exceed X value.
Profiler by Zeex?

And if it were recursive calls, he would get a stack overflow very quickly. An infinite loop is not related to recursion.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)