mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-09 21:29:08 +01:00
Move OOM try-catch
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
afdc67fc26
commit
1851ea7eca
@ -276,7 +276,13 @@ public class PlayerSocketConnection extends PlayerConnection {
|
|||||||
public void flush() {
|
public void flush() {
|
||||||
try {
|
try {
|
||||||
synchronized (bufferLock) {
|
synchronized (bufferLock) {
|
||||||
updateLocalBuffer();
|
try {
|
||||||
|
updateLocalBuffer();
|
||||||
|
} catch (OutOfMemoryError e) {
|
||||||
|
this.waitingBuffers.clear();
|
||||||
|
System.gc(); // Explicit gc forcing buffers to be collected
|
||||||
|
throw new ClosedChannelException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
synchronized (flushLock) {
|
synchronized (flushLock) {
|
||||||
try {
|
try {
|
||||||
@ -291,10 +297,6 @@ public class PlayerSocketConnection extends PlayerConnection {
|
|||||||
} catch (IOException e) { // Couldn't write to the socket
|
} catch (IOException e) { // Couldn't write to the socket
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
MinecraftServer.getExceptionManager().handleException(e);
|
||||||
throw new ClosedChannelException();
|
throw new ClosedChannelException();
|
||||||
} catch (OutOfMemoryError e) { // Couldn't allocate a pooled buffer
|
|
||||||
this.waitingBuffers.clear();
|
|
||||||
System.gc(); // Explicit gc forcing buffers to be collected
|
|
||||||
throw new ClosedChannelException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ClosedChannelException e) {
|
} catch (ClosedChannelException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user