# How to fix Freeze in EDT

**URL:** <https://platform.jetbrains.com/t/how-to-fix-freeze-in-edt/1761>\
**Category:** IntelliJ Platform\
**Created:** [May 21, 2025, 7:55am UTC](https://platform.jetbrains.com/t/how-to-fix-freeze-in-edt/1761 "2025-05-21T07:55:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kings](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/kings/32/382_2.png) [@kings](https://platform.jetbrains.com/u/kings)\
**Post date:** [May 21, 2025, 7:55am UTC](https://platform.jetbrains.com/t/how-to-fix-freeze-in-edt/1761/1 "2025-05-21T07:55:10Z")

</div>

The code `new ReformatCodeProcessor(PsiDocumentManager.getInstance(myProject).getPsiFile(document),false).runWithoutProgress();` report `Freeze in EDT for 12 seconds Sampled time: 3600ms, sampling rate: 100ms, GC time: 122ms (1%), Class loading: 0%, CPU load: 11%`

How to fix it?

```auto
Document document = getDocument();
        ((DocumentImpl)document).setAcceptSlashR(true);

        WriteCommandAction.runWriteCommandAction(
                myProject,
                () -> {
                    document.setText(finalText);
                    PsiDocumentManager.getInstance(myProject).commitDocument(document);
                    if(formatFlag && StringUtils.isNotBlank(finalText)){
                        new ReformatCodeProcessor(PsiDocumentManager.getInstance(myProject).getPsiFile(document),false).runWithoutProgress();
                    }
                }
        );

```

---

<div class="post-metadata">

**Author:** ![jojoatxgme](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/jojoatxgme/32/1550_2.png) [@jojoatxgme](https://platform.jetbrains.com/u/jojoatxgme)\
**Post date:** [January 4, 2026, 7:56pm UTC](https://platform.jetbrains.com/t/how-to-fix-freeze-in-edt/1761/2 "2026-01-04T19:56:38Z")

</div>

Just thought I link this here, as it might help people visiting this thread:

> [@Analyzing UI freezes in plugins guide](https://platform.jetbrains.com/t/analyzing-ui-freezes-in-plugins-guide/2841):
>
> Plugin authors inevitably encounter exceptions and UI freezes in user reports. These issues are often extremely difficult to investigate, as concurrency is a rather difficult domain. To simplify such investigations, let us present our guide on the reasons for UI freezes by Konstantin Nisht! Moreover, you can easily start analyzing thread dumps using the built-in Analyze Stacktrace or Thread Dump action. Copy the text to the clipboard and call the action from Search Every…

---

<div class="post-metadata">

**Author:** ![yuriy.artamonov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yuriy.artamonov/32/48_2.png) [@yuriy.artamonov](https://platform.jetbrains.com/u/yuriy.artamonov)\
**Post date:** [January 4, 2026, 9:53pm UTC](https://platform.jetbrains.com/t/how-to-fix-freeze-in-edt/1761/3 "2026-01-04T21:53:51Z")

</div>

Usual solution for such problems is running reformat as a modal task with progress and Cancel available. There will be no UI freeze for users then, but interactive UI with progress.

You may also want to remove reformat from the initial write action and do it asyncronously with `ReformatCodeProcessor` APIs.
