connection: cleanup errored if more than 5 available

This should reduce the big on disconnect memory leak. Not ideal still, but way better.
This commit is contained in:
Moritz Zwerger 2024-02-05 15:59:01 +01:00
parent 2ecfe983ca
commit aa12de78ac
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -119,6 +119,7 @@ class PlayConnection(
this::error.observe(this) {
if (errored || it == null) return@observe
ERRORED_CONNECTIONS += this
cleanupErrors()
state = PlayConnectionStates.ERROR
error.report()
errored = true
@ -274,5 +275,12 @@ class PlayConnection(
return result.toTypedArray()
}
private fun cleanupErrors() {
while (ERRORED_CONNECTIONS.size > 5) {
// we just keep 5 connections here, they are for crash reports
ERRORED_CONNECTIONS.iterator().remove()
}
}
}
}