sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
802 stars 38 forks source link

Indent command causes heavy RAM usage #1538

Closed deathaxe closed 6 months ago

deathaxe commented 7 years ago

Summary

I found a little issue with the indent command, which is called by pressing TAB key when several (or all) lines of text are selected. Pressing TAB with a 100k lines file of about 3.8MB of size opened as plain text causes Sublime Text to freeze for about 4 to 5 seconds, which is not really fast but acceptable. But RAM usage of Sublime Text 3 grows heavily to about 440MB then. This is really too much for a 3.8MB file. Considder doing so for 5 to 10 files! I guess some objects are not cleaned up after indenting is finished. As I opened the file as Plain Text I would exclude the lexer or symbol system from possible sources of issue.

I tried on Windows 10 x64 right now. But this issue might exist on the other platforms, too.

Expected behavior

Pressing TAB to indent a piece of text may use a bit more RAM while action is in progress, but after completion it should clean up and should not use so much more RAM. I would expect some MBs for Undo feature, but not 100x filesize.

I tried the same thing with SublimeText 2. It also needs some time to indent the text and uses quite a lot of RAM for this task. But as soon as indenting is completed RAM usage is like before.

Actual behavior

If the file is opened SublimeText uses about 17MB RAM. Pressing TAB key causes SublimeText to be busy for a while an RAM usage growing to about 440MB. The only way to reduce RAM usage to original value again is to close the view.

When closing Sublime Text (hot_exit: true) and opening it again, the previously indented file is still there as in its last state as expected and RAM usage is about 40MB, which is really OK.

Steps to reproduce

  1. Open a file with 100.000 lines of code as Plain Text (ca. 3.8MB)
  2. Select all (Ctrl+A)
  3. Press TAB
  4. Wait
  5. Have a look onto the task manager

Environment

keith-hall commented 7 years ago

Confirmed on Windows 7 x64. Note that this only happens the first time you indent the file - subsequent further indents don't cause more RAM to be used. I tried by typing lorem Tab on a new tab, and copying and pasting that til I got 100k lines. In my case, ST went from 70MB usage to 510MB and stayed there til I closed the tab. EDIT: indenting only a few lines does not exhibit the same behavior

keith-hall commented 7 years ago

Also related is un-indent performance: https://github.com/SublimeTextIssues/Core/issues/990

deathaxe commented 7 years ago

Still exists in ST 3131

BenjaminSchaaf commented 1 year ago

Is this fixed in the latest build @deathaxe ?

deathaxe commented 1 year ago

Just was doing some house keeping, closing stuff I gave upon or which haven't bothered me during the past few years.

Indenting 100k lines of plain text doesn't take 5s anymore - maybe 0,5-1s only. Dedenting is still slow - takes about 10-20s.

RAM usage is still pushed from 120MB to 550MB for such a file. But with all those language servers using 1GB RAM most of the time ... . As soon as such a file is closed, RAM usage drops to normal again.

BenjaminSchaaf commented 6 months ago

Reopening this as that still seems unacceptable.

BenjaminSchaaf commented 6 months ago

Fixed in build 4170.