mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Merge pull request #3088 from kfeuz/client_memory_leak
Prevent memory leak of Client by unregistering parent dispose method
This commit is contained in:
@@ -61,6 +61,7 @@ public class Client implements Runnable {
|
||||
int bufferIndex;
|
||||
int bufferLast;
|
||||
|
||||
boolean isDisposeRegistered = false;
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
@@ -81,6 +82,7 @@ public class Client implements Runnable {
|
||||
thread.start();
|
||||
|
||||
parent.registerMethod("dispose", this);
|
||||
isDisposeRegistered = true;
|
||||
|
||||
// reflection to check whether host sketch has a call for
|
||||
// public void clientEvent(processing.net.Client)
|
||||
@@ -158,6 +160,10 @@ public class Client implements Runnable {
|
||||
disconnectEventMethod = null;
|
||||
}
|
||||
}
|
||||
if(isDisposeRegistered){
|
||||
parent.unregisterMethod("dispose", this);
|
||||
isDisposeRegistered = false;
|
||||
}
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user