- Home /
what sort of thing is likely to cause my game (ran as server using -batchmode flag) to consume the entire CPU after about 8 hours of running?
I am running a version of my game using the -batchmode flag on a windows (VPS) server. It runs perfectly well for the first few hours but over a period of about 8 hours consumes my entire CPU Usage. I am not sure where to start to look for the culprit causing this.. (the 'output_log.txt' file gets quite large but surely writing to that can't be the culprit??)
any tips on the sort of thing i should be looking for in my code would be greatly appreciated
cheers andrew
Hi Andrew, did you find the cause of your troubles? A follow up comment might be useful for future reference. Cheers!
Answer by Ricardo · Apr 22, 2010 at 12:27 AM
Start by checking the machine's memory usage at that point. Is it significantly higher than when you started the process? How's the pagefile usage looking?
"Surely X can't be the culprit?" are famous last words. For instance, your logging probably does a lot of string concatenation and formatting. If you're doing that sub-optimally - for instance, using the + operator instead of a stringbuilder and string.Format - the resulting allocation and destruction of strings could have an effect on Mono's less-than-ideal garbage collector (see these two articles). While StringBuilder is not always faster, it's memory fragmentation that you should care about the most.
While I'm not saying that logging is the culprit, it's a good example of things that might be non-obvious at first but where you want to start checking your memory allocation and usage patterns.
Answer by KHopcraft · Apr 21, 2010 at 04:42 PM
There is most likely a leak somewhere in your games code. I would reccommend asking on the unity forums for more help.
No reason why he couldn't get help finding it here, actually.
I know, but the forum has a lot more traffic, and with a problem like this I just figured it would be better in the forums :o.
Your answer
Follow this Question
Related Questions
Optimizing Headless Servers 2 Answers
Reducing server-side application size 0 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
running servers for networked games 0 Answers
What does the headless build option do? 3 Answers