[Pogamut-list] Proper Server Termination

jacob.schrum pogamut-forum at diana.ms.mff.cuni.cz
Sun Apr 24 02:22:04 CEST 2011


Re: Proper Server Termination

Author: jacob.schrum

Ok, some more questions related to server/bot termination. I've discovered that my code definitely has a memory leak,
and maybe also a Thread leak, with the help of the NetBeans profiler. I verified a few things:

If I run my bot by itself against an opponent on an externally launched server, there is no memory/thread leak.

If I run my evolution code, but make it launch only one server with an unlimited time limit (so basically, one server
gets launched with some bots), there is no memory/thread leak.

If I evolve using just one server at a time (no multithreading, but still using the same code that can launch multiple server threads),
with a population size of 1 for several generations, the code leaks both memory and threads.

I'm not sure of the cause, but I have some theories and a little data that I'm hoping will help.
I'm wondering if whenever I stop/kill a server/bot, the resulting FatalErrorEvent is not closing
all the running threads, and therefore not freeing the memory used by objects in those threads.
How do I completely wipe out all objects and threads created by a server/bot? Simply using stop/kill
doesn't seem to work. I've noticed in some of the Pogamut code interesting use of various sync tools,
such as listeners for state changes, countdown latches, and things like that, but before I start
trying to copy this code, I was wondering if anyone could help explain what is necessary and how/why
it works.

Also, although the profiler lets me look at the allocated objects, it crashes whenever I try to use the
"Record stack trace for allocations" option, so I'm not able to find the exact sources of the classes
that are causing the problem. However, from looking at the number, age, and surviving generations
of the different classes, I can say that the following seem to be causing problems:

HashMaps, ArrayLists, Locations, Strings, char arrays and Object arrays. The char arrays are inside the
Strings, and the Object Arrays are inside the ArrayLists. Strings are probably the keys for a lot of the HashMaps,
and Locations are probably what's being looked up. From all of this, I have the feeling that navigation and
path planning information is not being cleared out when the bots die, but maybe I'm jumping to conclusions.
Without the ability to follow the stack traces, I can't know for certain.

On the thread side, RMI connections, sockets, and TCP connections seem to be responsible. These threads
tend to stay alive long after they should be closed.

I can provide more specific profiler data if needed. I would really like to figure this out.

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=682&post_reply=1#form>





More information about the Pogamut-list mailing list