Skip to content

KSPCoreEnvironment.instance_prop leaks memory when used programmatically #2742

@ZacSweers

Description

@ZacSweers

Currently the CLI appears to be designed for use as a single-shot. However, if KSP is invoked programmatically in a reused thread (such as in github.com/zacsweers/kotlin-compile-testing for unit testing), this becomes a source of memory leaks. It gets worse when tests are spread across multiple threads/workers as well. I've worked around this now in that library by manually clearing that after each run.

https://github.com/google/ksp/blob/main/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/KSPCoreEnvironment.kt#L25-L26

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions