Skip to content

Commit d632013

Browse files
committed
- log exceptions when memory usage cannot be determined
- stop the clock when calculating the memory usage
1 parent 9bd8517 commit d632013

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Chess-Challenge/src/Framework/Application/Core/ChallengeController.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,22 @@ void OnMoveChosen(Move chosenMove)
236236
playMoveTime = lastMoveMadeTime + MinMoveDelay;
237237
if (PlayerToMove.Bot is MyBot)
238238
{
239-
maxMemoryUsed = Math.Max(ObjectSizeHelper.GetSize(PlayerToMove.Bot), maxMemoryUsed);
239+
isPlaying = false;
240+
try
241+
{
242+
maxMemoryUsed = Math.Max(ObjectSizeHelper.GetSize(PlayerToMove.Bot), maxMemoryUsed);
243+
}
244+
catch (Exception e)
245+
{
246+
Log("An error occurred while determining used memory size.\n" + e.ToString(), true,
247+
ConsoleColor.Red);
248+
hasBotTaskException = true;
249+
botExInfo = ExceptionDispatchInfo.Capture(e);
250+
}
251+
finally
252+
{
253+
isPlaying = true;
254+
}
240255
}
241256
}
242257
else

0 commit comments

Comments
 (0)