Fix memory leak in GameServer (#731)

* Convert entities to serializable after aggregating rather before

* Cache instances of CustomXmlSerializer and create readonly constants for reused settings

* Change CustomXmlSerializer and serializer cache to work with deserializer
This commit is contained in:
Josh 2023-04-02 18:45:19 -05:00 committed by GitHub
parent 0253864f5e
commit 2210541894
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 125 additions and 147 deletions

View file

@ -322,7 +322,7 @@ public class ScoreController : ControllerBase
// Paginated viewing: if not requesting pageStart, get results around user
var pagedScores = rankedScores.Skip(options.PageStart != -1 || myScore == null ? options.PageStart - 1 : myScore.Rank - 3).Take(Math.Min(options.PageSize, 30));
List<GameScore> gameScores = pagedScores.Select(ps => GameScore.CreateFromEntity(ps.Score, ps.Rank)).ToList();
List<GameScore> gameScores = pagedScores.ToSerializableList(ps => GameScore.CreateFromEntity(ps.Score, ps.Rank));
return new ScoreboardResponse(options.RootName, gameScores, rankedScores.Count, myScore?.Score.Points ?? 0, myScore?.Rank ?? 0);
}