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
asked Apr 21 '10 at 12:11 PM
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.
There is most likely a leak somewhere in your games code. I would reccommend asking on the unity forums for more help.
answered Apr 21 '10 at 04:42 PM