Skip to content

Commit 4352492

Browse files
Track the case of language server OutOfMemory (#3273)
1 parent 8dac160 commit 4352492

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/extension.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,16 @@ async function showOOMMessage(): Promise<void> {
6464
}
6565
}
6666

67+
function getMaxMemFromConfiguration(includeUnit?: boolean): string | undefined {
68+
const jvmArgs: string = getJavaConfiguration().get('jdt.ls.vmargs');
69+
const results = includeUnit ? MAX_HEAP_SIZE_EXTRACTOR_WITH_UNIT.exec(jvmArgs)
70+
: MAX_HEAP_SIZE_EXTRACTOR.exec(jvmArgs);
71+
return results && results[0] ? results[1] : undefined;
72+
}
73+
6774
const HEAP_DUMP_FOLDER_EXTRACTOR = new RegExp(`${HEAP_DUMP_LOCATION}(?:'([^']+)'|"([^"]+)"|([^\\s]+))`);
6875
const MAX_HEAP_SIZE_EXTRACTOR = new RegExp(`-Xmx([0-9]+)[kKmMgG]`);
76+
const MAX_HEAP_SIZE_EXTRACTOR_WITH_UNIT = new RegExp(`-Xmx([0-9]+[kKmMgG])`);
6977

7078
/**
7179
* Returns the heap dump folder defined in the user's preferences, or undefined if the user does not set the heap dump folder
@@ -980,6 +988,12 @@ function registerOutOfMemoryDetection(storagePath: string) {
980988
if (heapDumpFolder === storagePath) {
981989
fse.remove(path);
982990
}
991+
apiManager.fireTraceEvent({
992+
name: "java.process.outofmemory",
993+
properties: {
994+
maxMem: getMaxMemFromConfiguration(true),
995+
}
996+
});
983997
showOOMMessage();
984998
serverStatusBarProvider.setError();
985999
activationProgressNotification.hide();

0 commit comments

Comments
 (0)