IJ-CR-153499 LLM-12106 Fix thread leak of threads related to the native server process

(cherry picked from commit df6564497af87d2f9ebaa75e52de18e9148a4f73)

GitOrigin-RevId: 676cb38dfb2ff8e9b4588838bd37c16a62f8e849
This commit is contained in:
Evgeny Abramov
2024-12-09 21:49:09 +02:00
committed by intellij-monorepo-bot
parent 27c94c9e0a
commit c961778f94
3 changed files with 10 additions and 1 deletions

View File

@@ -65,6 +65,8 @@ public final class ThreadLeakTracker {
"AWT-EventQueue-",
"AWT-Shutdown",
"AWT-Windows",
"BaseDataReader: error stream of embeddings-server",
"BaseDataReader: output stream of embeddings-server",
"BatchSpanProcessor_WorkerThread", // io.opentelemetry.sdk.trace.export.BatchSpanProcessor.WORKER_THREAD_NAME
"Batik CleanerThread",
"BC Entropy Daemon",
@@ -74,11 +76,13 @@ public final class ThreadLeakTracker {
"CompilerThread0",
"Coroutines Debugger Cleaner", // kotlinx.coroutines.debug.internal.DebugProbesImpl.startWeakRefCleanerThread
"dockerjava-netty",
"embeddings-server",
"External compiler",
FilePageCacheLockFree.DEFAULT_HOUSEKEEPER_THREAD_NAME,
"Finalizer",
FlushingDaemon.NAME,
"grpc-default-worker-", // grpc_netty_shaded
"grpc-nio-worker-",
"HttpClient-", // JRE's HttpClient thread pool is not supposed to be disposed - to reuse connections
ProcessIOExecutorService.POOLED_THREAD_PREFIX,
"IDEA Test Case Thread",

View File

@@ -95,6 +95,7 @@ a:com.intellij.execution.process.BaseProcessHandler
- pf:myProcess:java.lang.Process
- pf:myWaitFor:com.intellij.execution.process.ProcessWaitFor
- <init>(java.lang.Process,java.lang.String,java.nio.charset.Charset):V
- p:createWaitFor():com.intellij.execution.process.ProcessWaitFor
- p:destroyProcessImpl():V
- detachIsDefault():Z
- p:detachProcessImpl():V

View File

@@ -34,7 +34,7 @@ public abstract class BaseProcessHandler<T extends Process> extends ProcessHandl
LOG.warn(new IllegalArgumentException("Must specify non-empty 'commandLine' parameter"));
}
myPresentableName = CommandLineUtil.extractPresentableName(StringUtil.notNullize(commandLine));
myWaitFor = new ProcessWaitFor(process, this, myPresentableName);
myWaitFor = createWaitFor();
}
public final @NotNull T getProcess() {
@@ -60,6 +60,10 @@ public abstract class BaseProcessHandler<T extends Process> extends ProcessHandl
closeStreams();
}
protected ProcessWaitFor createWaitFor() {
return new ProcessWaitFor(myProcess, this, myPresentableName);
}
protected void doDestroyProcess() {
getProcess().destroy();
}