# Found a leaked instance of class com.intellij.openapi.project.impl.ProjectImpl

**URL:** <https://platform.jetbrains.com/t/found-a-leaked-instance-of-class-com-intellij-openapi-project-impl-projectimpl/3123>\
**Category:** IntelliJ Platform\
**Tags:** plugin-development\
**Created:** [November 15, 2025, 6:21pm UTC](https://platform.jetbrains.com/t/found-a-leaked-instance-of-class-com-intellij-openapi-project-impl-projectimpl/3123 "2025-11-15T18:21:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin.hauner](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/martin.hauner/32/291_2.png) [@martin.hauner](https://platform.jetbrains.com/u/martin.hauner)\
**Post date:** [November 15, 2025, 6:21pm UTC](https://platform.jetbrains.com/t/found-a-leaked-instance-of-class-com-intellij-openapi-project-impl-projectimpl/3123/1 "2025-11-15T18:21:18Z")

</div>

Hi,

I’m trying to re-implement my plugin tests using junit5/TestApplication, 2025.2 platform. I have removed all old tests, updated the dependencies and added a single test. The test itself runs but the “test run” complains about the `Project` not getting disposed:

```auto
java.lang.AssertionError: Found a leaked instance of class com.intellij.openapi.project.impl.ProjectImpl
Instance: Project(name=light_temp_35Wa8RMcgSieeFBU70czxitkimA, containerState=disposed temporarily, componentStore=/private/var/folders/8w/jcbd06095qxb0379t1rs9rfr0000gn/T/unitTest__35Wa8OrBgVBCyRedKl3uDYxFpdj/light_temp_35Wa8RMcgSieeFBU70czxitkimA.ipr) (disposed)

.. stripped ...

The instance was created at: Project(name=light_temp_35Wa8RMcgSieeFBU70czxitkimA, containerState=disposed temporarily, componentStore=/private/var/folders/8w/jcbd06095qxb0379t1rs9rfr0000gn/T/unitTest__35Wa8OrBgVBCyRedKl3uDYxFpdj/light_temp_35Wa8RMcgSieeFBU70czxitkimA.ipr) (disposed) 2025-11-15T18:35:27.412761@java.lang.Throwable
at com.intellij.util.ExceptionUtil.currentStackTrace(ExceptionUtil.java:79)
at com.intellij.openapi.project.impl.ProjectImpl.storeCreationTrace(ProjectImpl.kt:410)
at com.intellij.openapi.project.impl.ProjectImpl.setLightProjectName(ProjectImpl.kt:340)
at com.intellij.testFramework.LightPlatformTestCase.doSetup(LightPlatformTestCase.java:275)
at com.intellij.testFramework.fixtures.impl.LightIdeaTestFixtureImpl.setUp(LightIdeaTestFixtureImpl.java:41)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$setUp$42(CodeInsightTestFixtureImpl.java:1377)
at com.intellij.testFramework.EdtTestUtil.lambda$runInEdtAndWait$3(EdtTestUtil.java:87)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:240)

```

my test looks like this:

```auto
@TestApplication
class FileTypeSpec : LightJavaCodeInsightFixtureTestCase5() {

  override fun getTestDataPath(): String {
    return "src/test/testdata/filetype"
  }

  private fun loadFile(path: String): VirtualFile {
    return fixture.configureByFile(path).virtualFile
  }

  @Test
  fun `detects file type with 'yaml' extension`() {
    val mapping = loadFile("mapping.yaml")
    assertEquals(TypeMappingFileType.NAME, mapping.fileType.name)
  }

} 

```

I can open the heap dump, I can find the tested class in it… but I don’t really know what to look for. 😉

Any idea how to make that work? Is this an issue with my plugin? If my plugin should do some clean up, how do I find what/where it is missing?

> <https://github.com/openapi-processor/openapi-processor-intellij/blob/main/src/test/kotlin/io/openapiprocessor/intellij/FileTypeSpec.kt>

---

<div class="post-metadata">

**Author:** ![sergei.tachenov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/sergei.tachenov/32/2053_2.png) [@sergei.tachenov](https://platform.jetbrains.com/u/sergei.tachenov)\
**Post date:** [November 17, 2025, 8:02am UTC](https://platform.jetbrains.com/t/found-a-leaked-instance-of-class-com-intellij-openapi-project-impl-projectimpl/3123/2 "2025-11-17T08:02:13Z")

</div>

That message should also print existing strong paths to the leaked instance.

If that path doesn’t contain anything from your plugin, it’s either a bug in the platform or you’re using it in the wrong way. I lack the necessary expertise to tell which is this, but I have one question: do you really need `@TestApplication` here? I’ve just checked, and it seems `LightJavaCodeInsightFixtureTestCase5` initializes an application by itself (at least `ApplicationManager.getApplication()` returns a non-null value) and there are no leaks if I remove `@TestApplication` from your example. Maybe that’s the issue?

I also see some `LightJavaCodeInsightFixtureTestCase5` tests in our codebase, but none of them uses `@TestApplication`. I’m not saying it _shouldn’t_ be used, I just don’t know.

---

<div class="post-metadata">

**Author:** ![martin.hauner](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/martin.hauner/32/291_2.png) [@martin.hauner](https://platform.jetbrains.com/u/martin.hauner)\
**Post date:** [November 17, 2025, 8:05am UTC](https://platform.jetbrains.com/t/found-a-leaked-instance-of-class-com-intellij-openapi-project-impl-projectimpl/3123/3 "2025-11-17T08:05:50Z")

</div>

after removing `@TestApplication` it just works…

what is the rule for `@TestApplication` ? Where can/should I use it?

---

<div class="post-metadata">

**Author:** ![jansorg](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/jansorg/32/52_2.png) [@jansorg](https://platform.jetbrains.com/u/jansorg)\
**Post date:** [November 17, 2025, 9:12am UTC](https://platform.jetbrains.com/t/found-a-leaked-instance-of-class-com-intellij-openapi-project-impl-projectimpl/3123/4 "2025-11-17T09:12:00Z")

</div>

If I’m not mistaken, `LightJavaCodeInsightFixtureTestCase5` is to ease moving from JUnit4 to JUnit5, but it’s not using the annotations also introduced for JUnit5 support.

See [intellij-community/platform/testFramework/junit5/test/showcase at master · JetBrains/intellij-community · GitHub](https://github.com/JetBrains/intellij-community/tree/master/platform/testFramework/junit5/test/showcase) how to use annotations and fixtures with JUnit5 without a base class.

---

<div class="post-metadata">

**Author:** ![martin.hauner](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/martin.hauner/32/291_2.png) [@martin.hauner](https://platform.jetbrains.com/u/martin.hauner)\
**Post date:** [November 18, 2025, 8:12am UTC](https://platform.jetbrains.com/t/found-a-leaked-instance-of-class-com-intellij-openapi-project-impl-projectimpl/3123/5 "2025-11-18T08:12:51Z")

</div>

Thanks for the tip. 🙂

I tried that first and didn’t get it running. ☹ Not sure, I think I didn’t find an example that uses test data files and `@TestDataPath` didn’t work for me.

Maybe I try that again…
