Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/solidlsp/language_servers/kotlin_language_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
ls_specific_settings:
kotlin:
jvm_options: '-Xmx4G -XX:+UseG1GC'

IntelliJ system directory:
KLS is built on IntelliJ's platform, which by default creates a new ~52 MB
idea-system<random>/ directory in /tmp for each instance. These directories
are never cleaned up, which can exhaust RAM on tmpfs systems after many runs.
Serena redirects idea.system.path to <ls_resources_dir>/kotlin_language_server/system/,
making it a bounded per-project cache that persists across sessions (faster restarts).
"""

import logging
Expand Down Expand Up @@ -146,7 +153,18 @@ def create_launch_command_env(self) -> dict[str, str]:
else:
jvm_options = DEFAULT_KOTLIN_JVM_OPTIONS

env["JAVA_TOOL_OPTIONS"] = jvm_options
# Redirect IntelliJ's system directory to a stable path under ls_resources_dir.
# Without this, each KLS instance creates a new ~52 MB /tmp/idea-system<random>/ directory
# that is never removed on shutdown. On tmpfs systems this causes unbounded RAM consumption
# (e.g. 329 stale directories totalling 30 GiB after repeated test runs).
# Using a fixed path makes it a bounded per-project cache and preserves the IntelliJ index
# across sessions for faster restarts.
system_dir = os.path.join(self._ls_resources_dir, "kotlin_language_server", "system")
os.makedirs(system_dir, exist_ok=True)
idea_system_path_opt = f"-Didea.system.path={system_dir}"
jvm_options_full = f"{jvm_options} {idea_system_path_opt}".strip() if jvm_options else idea_system_path_opt

env["JAVA_TOOL_OPTIONS"] = jvm_options_full
return env

@staticmethod
Expand Down
Loading