Using the latest release (1.010), we have again encountered a stalled AI (0 AI commands issued after a half-hour of game time) and another OutOfMemoryException:
2009-07-20 20:59:06
-----------------------------------Application_ThreadException-----------------------------------System.Exception: Game Command Text:0|25|-1|-1|-1|0|0|0|-1|-1|0|
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.String.ToCharArray()
at System.Text.Encoding.GetBytes(String s)
at AIWar.Compressor.CompressStringBig(String text, Int32 CompressionLevel) in C:\vcprojs\AIWar\Framework\Compressor.cs:line 15
at AIWar.GameForm.DoFullSync(Boolean IsForSave, Boolean IsForDump, Boolean ShowDialogs, Int32 JustForPlayerNumber) in C:\vcprojs\AIWar\GameFormParts\NetworkHandling.cs:line 1516
at AIWar.GameForm.DoSaveGame(String Filename, Boolean ShowDialogs) in C:\vcprojs\AIWar\GameFormParts\NetworkHandling.cs:line 1402
at AIWar.GameCommand.Execute() in C:\vcprojs\AIWar\Framework\GameCommand.cs:line 694
at AIWar.GameForm.RunNextCycle(Boolean DoRendering, Boolean DoScrollingAndInput) in C:\vcprojs\AIWar\GameFormParts\GameLoop.cs:line 480
at AIWar.GameForm.RunNextCycle(Boolean DoRendering, Boolean DoScrollingAndInput) in C:\vcprojs\AIWar\GameFormParts\GameLoop.cs:line 486
at AIWar.GameForm.gameLoop() in C:\vcprojs\AIWar\GameFormParts\GameLoop.cs:line 243
at AIWar.GameForm.GameForm_Load(Object sender, EventArgs e) in C:\vcprojs\AIWar\GameFormParts\Startup.cs:line 274
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
2009-07-20 20:59:17
-----------------------------------CurrentDomain_UnhandledException-----------------------------------System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.String.Concat(String str0, String str1)
at SlimDX.ObjectTable.ReportLeaks()
at SlimDX.ObjectTable.OnExit(Object sender, EventArgs e)
Prior to the crash, I noticed the reused objects count go up by several thousand per second. I don't recall seeing that before, and I wish I had a screenshot of just before the crash, but unfortunately I don't. If I can reproduce, I will get one. The game slowed down considerably just prior to the crash.
Now regarding the AI stall:
Since you suggested that this exception and the AI stalling may have been related, I will be including both bugs in this thread instead of continuing in the Potential 1.009F thread for the stalling AI.
It looks like no messages are queued or AI commands done. If I can reproduce it next week, I will attach a screenshot of F3 debug after 1000 game seconds. Since we have AI progress around 900, I would have expected to see more in 4 hours of play, but there was nothing. Ships fought back, but there were no AI reinforcements, no raids, nor any trickling or groups of AI coming through the outlying wormholes. Both CPU cores were at about 96% busy at the time, so it seems like it was processing something, but it certainly wasn't processing any AI commands. When not in battle, the game was running quite smoothly even while the AI was stalled. It doesn't seem like the AI was stalling because the CPU couldn't keep up with it, but this could have been the result of minimal locking in the AI thread.
It appears as though the AI thread is getting into an infinite logic loop of some kind where it is unable to completely post any messages or commands (but it may be continually creating them or some other objects that may be causing the OutOfMemoryException). If the AI thread doesn't issue or process commands when there is not enough time available, then a minimum should be established to ensure that it can proceed under these conditions.
- Kal