mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
remove thread from thread group on termination
In the OpenJDK library, ThreadGroup maintains an array of all Threads in that group, so the VM must explicitly remove threads as they exit or else neither they nor any objects they reference will be eligable for GC.
This commit is contained in:
parent
c6185c8034
commit
84f99f0dca
@ -1231,10 +1231,11 @@ class Machine {
|
||||
Shutdown,
|
||||
VirtualFileFinders,
|
||||
VirtualFiles,
|
||||
ArrayInterfaceTable
|
||||
ArrayInterfaceTable,
|
||||
ThreadTerminated
|
||||
};
|
||||
|
||||
static const unsigned RootCount = ArrayInterfaceTable + 1;
|
||||
static const unsigned RootCount = ThreadTerminated + 1;
|
||||
|
||||
Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder,
|
||||
Processor* processor, Classpath* classpath, const char** properties,
|
||||
|
@ -613,6 +613,10 @@ class MyClasspath : public Classpath {
|
||||
t->flags &= ~Thread::ActiveFlag;
|
||||
vm::notifyAll(t, t->javaThread);
|
||||
vm::release(t, t->javaThread);
|
||||
|
||||
t->m->processor->invoke
|
||||
(t, root(t, Machine::ThreadTerminated),
|
||||
threadGroup(t, t->javaThread), t->javaThread);
|
||||
});
|
||||
|
||||
object method = resolveMethod
|
||||
@ -653,6 +657,10 @@ class MyClasspath : public Classpath {
|
||||
resolveSystemClass(t, root(t, Machine::BootLoader),
|
||||
className(t, type(t, Machine::ClassLoaderType)));
|
||||
|
||||
setRoot(t, Machine::ThreadTerminated, resolveMethod
|
||||
(t, root(t, Machine::BootLoader), "java/lang/ThreadGroup",
|
||||
"threadTerminated", "(Ljava/lang/Thread;)V"));
|
||||
|
||||
#ifdef AVIAN_OPENJDK_SRC
|
||||
interceptFileOperations(t);
|
||||
#else // not AVIAN_OPENJDK_SRC
|
||||
|
Loading…
Reference in New Issue
Block a user