Page 1 of 1

Memory errors

Posted: 13 Mar 2007, 17:40
by endquote
My server is currently running 18 games with up to a few users in each. I've refactored the whole thing to live in a single zone extension. There is very little data that remains in memory outside the scope of a function.

However I still get memory errors after the server has been running for a while (~8hrs).

Code: Select all

Exception in thread "Timer-13" java.lang.OutOfMemoryError: Java heap space
Exception in thread "selector" java.lang.OutOfMemoryError: Java heap space
2007-03-12 16:54:39.849::WARN:  EXCEPTION 
java.lang.OutOfMemoryError: Java heap space
Exception in thread "extensionReloader" java.lang.OutOfMemoryError: Java heap space
This seems to be happening in the interval which controls the clock for the game instances. It runs every second and most of the time does nothing -- but sometimes ends a "round" of the game when the game logic dictates.

The memory usage is about 58MB right now, with 32 threads running. How can I troubleshoot this?

Posted: 13 Mar 2007, 17:41
by endquote
The bit about extensionReloader is interesting -- does this have something to do with AutoReloadExtensions?

Re: Memory errors

Posted: 14 Mar 2007, 06:31
by patso
You mention about the errors comes after the server works some hours.
May be the problem is the interval thread.
First I suppose you use only one interval. Seconds are you sure if it's not the problem - i mean the code in the thread. May be it creates some objects or keep references to other objects that are not deleted because there are references to them, even if you don't need them.
You can increase the Java heap but if the problem is that the memory usage increase by the time not by the server load(i mean users,rooms and so on) this will not solve your problem.
If the memory usage increase by the time not by the server load I suppose that there are objects that are created but for some reason are not collected by the garbage collector - in simple words somewhere and for some reasons there are references to them.
About the extensionReloader - I don't know only Lapo can say if the problem is here. To be sure you can turn off the AutoReloadExtensions.

Posted: 15 Mar 2007, 14:19
by endquote
I think this is a bug in AutoReloadExtensions. I turned it off and the server has been running fine for about 16hrs now.

Posted: 21 Mar 2007, 09:33
by Lapo
As mentioned in the docs we recommend to turn the autoreload feature OFF when the application goes live.

Posted: 22 Mar 2007, 04:30
by endquote
Well sure, but it still shouldn't crash, even in a dev environment.

Posted: 22 Mar 2007, 07:42
by Lapo
We don't have any other reports of the server crashing with the autoReload turned on, nor we ever experienced one in many months of testing.

The exahustion of the heap space indicates that in every reload of your extension you're adding new resources without freeing up those that were allocated previously.
I'd suggest to investigate in that direction.