New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add_regions causes Sublime Text to hang for ever after eating 1.81GB of RAM #1846
Comments
One of the ST developers briefly mentioned that ST expects that there won't be many unique |
Possibly related with the out of memory exception described here: https://forum.sublimetext.com/t/security-flaw-cve-2017-8368/30403/5 |
add_regions with a global custom dictionary like object. add_regions causes Sublime Text to hang for ever after eating 1.81GB of RAM sublimehq/sublime_text#1846
This no longer reproduces in ST4: Screencast.from.2023-10-26.15-20-32.webm |
Your RAM jumped from 25.5GB to 26.4GB (900MB). In my original post, I am only monitoring the RAM usage of Sublime Text in my system. So, your reproduction should make Sublime Text use more than 1.81GB instead of 0.9GB. I was also using Sublime Text x86 for Windows instead of Sublime x64. x86 application usually cannot use more RAM because of the limitations of x86 architecture. The limitation of x86 RAM usage is not a problem, just that add_regions uses too much RAM. |
Unsurprisingly adding |
Thanks for looking into it. Next time I will try using this |
Summary
After a few hours working over it, I figured out why it is crashing after typing text into Sublime Text. What did I do to figure it out? First I had to find out a automated way to make Sublime Text crash. While walking I remembered about automatic typers, i.e., computer programs which type text on the computer. Then voila, I figured out how to make Sublime Text crash while type text for few hours.
Now I need find out if was the Sublime Text core or some package doing some weird stuff. In the end, after find out exactly the code lines doing such, I am not sure whether it is the packages fault, or the Sublime Text's core. Here I listed all Sublime Text packages I got installed:
After gathering these data, I followed the procedures, following with a recorded video to register the behavior for future references, while I tested how Sublime Text would behavior to the stress test:
The test computer characteristics are:
Processor Intel i3-390M
@2.67 GHz
: (Underclocked to 1 GHz)RAM 8 GB DDR3
@1067 MHz
:GPU Intel(R) HD Graphics 64 MB of RAM
But before start, I created a complete Sublime Text vanilla install, (except for the settings:
"font_size": 11, "highlight_line": true,
). It keeps a correct behavior, with no memory increases or crashes. Within a the memory usage of23 MB
all runtime along:* https://vid.me/2ISqa (Sublime Text Vanilla Test)
First I put all the packages listed above on the
"ignored_packages"
list:* https://vid.me/G2SZb (Sublime Text Disabled Packages Test)
As may be noticed, Sublime Text keeps the same behavior as on the vanilla install, except for the initial memory amount usage, which is
48 MB
.Next I put 28 packages on the
"ignored_packages"
list, while keeping all other 127 running free:* https://vid.me/mW6Ky (Sublime Text Packages Crashing 1)
Now, Sublime Text starts leaking memory after 1 minute of the video running. When it got on the minute
6:17
, Sublime Text stops responding and starts using the kernel Time, instead of the user time:And crashes on the minute
7:15
when I tried to interact with it, generating a dump file withsize 0
. Worth notice, Sublime Text only crashed when forced a interaction, by clicking on its window. If I did not attempted it, Sublime Text would still be running unresponsive, on kernel time, but not crashing.As last time, but now there are only 63 packages enabled and 92 packages on the
"ignored_packages"
list:* https://vid.me/A6702 (Sublime Text Packages Crashing 2)
Sublime Text crashes again, now only more 63 packages to go on and disable.
Now there are only 31 packages enabled and 124 packages on the
"ignored_packages"
list:* https://vid.me/WY6cx (Sublime Text Packages Crashing 3)
Sublime Text crashes again, now only more 31 packages to go on and disable.
Now there are only 15 packages enabled and 140 packages on the
"ignored_packages"
list:* https://vid.me/zufZp (Sublime Text Packages Crashing 4)
Wow, now Sublime Text does not crashes! Meaning, one of the 16 packages I just disabled was bugging Sublime Text. They were:
That is the end of our journey. After a few making off tests more, I finally nailed it down to the package:
Expected behavior
There are a few mutual-exclusive expectations which came from interpreting what the
"GotoLastEditEnhanced"
package is actually doing:"GotoLastEditEnhanced"
is leaking memory, not let the package leak so much memory and make Sublime Text to crash from it. Related to: Packages are allowed to hang Sublime Text Indefinitely #1463 (Packages are allowed to hang Sublime Text Indefinitely).Actual behavior
As long as more characters are inserted, the Sublime Text RAM usage increases, where it completely stops responding to user input, and start using only CPU kernel time. See https://vid.me/WY6cx (Sublime Text Packages Crashing 3). On this animation, we see my Sublime Text having it RAM usage increases:
Code used
Open Sublime Text console and run the command:
sublime.active_window().active_view().run_command( "bug" )
With @Wramberg pull request the
"GotoLastEditEnhanced"
history is now limited until certain steps count as 5000:However Sublime Text still leaking memory even with that patch. On the following section Sublime Text build 3142, vanilla install, the only package installed on this vanilla install, was the
"GotoLastEditEnhanced"
patched at (shagabutdinov/sublime-goto-last-edit-enhanced#4):Sublime Text build 3142, vanilla install
The performance compared with build 3141, is incredibly higher (the videos above where recorded on build 3141, except this section which is on build 3142). Now Sublime Text stays responsive until it reaches
1.81GB
of RAM memory. Then it stops responding, until I close it. Here we may notice the when Sublime Text hanged, it started eating the kernel time (green line) on the CPU graphic:On this animation bellow, it last word typed was
Today
. After that Sublime Text stayed unresponsive, but no crash reports when asked to be closed:Steps to reproduce
Set up the typer program to type the text I was typing when it originally crashed several times.
The program is: https://www.murgee.com/auto-typer/ Auto Typer to Automatically Type on Keyboard
And its settings are:
After setup the typer program, open a Sublime Text vanilla install and create this package:
Now open the
Auto Typer
to automatically type text on Keyboard.Configure it as described on the Step 1 to type the text following text:
Text Used
Open some program to monitor the Sublime Text CPU and RAM usage.
Focus on an empty Sublime Text view and press
F8
to the typer program start typing.Environment
dpi_scale
used in ST 1.0The videos presented here, where recorded on Sublime Text build 3141. But on the middle of the time I as writing this issue, the Sublime Text build 3142 was released. Then I created a new topic called Sublime Text build 3142, vanilla install testing this issue on the new build 3142.
Related issues:
The text was updated successfully, but these errors were encountered: