Skip to content

fix(kotlin): redirect idea.system.path to prevent stale /tmp dirs#1130

Open
zerone0x wants to merge 1 commit intooraios:mainfrom
zerone0x:fix/kotlin-idea-system-tmpdir-leak
Open

fix(kotlin): redirect idea.system.path to prevent stale /tmp dirs#1130
zerone0x wants to merge 1 commit intooraios:mainfrom
zerone0x:fix/kotlin-idea-system-tmpdir-leak

Conversation

@zerone0x
Copy link
Contributor

@zerone0x zerone0x commented Mar 5, 2026

Summary

Fixes #1087

The Kotlin Language Server (KLS) is built on IntelliJ's platform, which by default creates a new idea-system<random>/ directory in /tmp for each instance. These directories are never removed on shutdown, causing unbounded accumulation.

On tmpfs systems (the default on modern Linux), this means unbounded RAM consumption — the issue author observed 329 stale directories totalling 30 GiB after repeated test runs.

Fix

In DependencyProvider.create_launch_command_env(), append -Didea.system.path=<ls_resources_dir>/kotlin_language_server/system/ to JAVA_TOOL_OPTIONS. This redirects IntelliJ to a fixed, per-project location instead of /tmp/idea-system<random>/.

The chosen location (ls_resources_dir/kotlin_language_server/system/) is:

  • Bounded: one directory per project (not one per run)
  • Persistent: IntelliJ index is preserved across sessions → faster restarts
  • Controlled: within Serena's own resource directory, not system-wide /tmp

Changes

  • src/solidlsp/language_servers/kotlin_language_server.py
    • create_launch_command_env(): compute system_dir, create it, and append -Didea.system.path to JAVA_TOOL_OPTIONS
    • Updated module docstring to document the IntelliJ system directory behaviour

Testing

The fix can be verified by running the Kotlin language server tests and confirming that no new idea-system* directories appear in /tmp during the test run, while <ls_resources_dir>/kotlin_language_server/system/ is populated instead.


🤖 Generated with Claude Code

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 on shutdown.

On tmpfs systems (the default on modern Linux) this causes unbounded
RAM consumption — e.g. 329 accumulated directories totalling 30 GiB
after repeated test runs.

Fix: append -Didea.system.path=<ls_resources_dir>/kotlin_language_server/system/
to JAVA_TOOL_OPTIONS in create_launch_command_env(). This redirects
IntelliJ to a fixed, bounded per-project cache directory that also
persists across sessions for faster restarts.

Fixes oraios#1087

Co-Authored-By: Claude <noreply@anthropic.com>
# (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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self._ls_resources_dir is already specific to the Kotlin LS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(kotlin): KLS leaves stale idea-system* temp dirs in /tmp, consuming RAM on tmpfs systems

2 participants