sublimehq / sublime_text

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

Very large memory leak on Windows 10. #4092

Closed absop closed 3 years ago

absop commented 3 years ago

Description

Very large memory leak on Windows 10.

Steps to reproduce

I met 2 times of this case accidentally, but I don't know how to reproduce it.

In the screen shot shown below: after I had worked within Sublime Text 4 a long time, my system become slow, then I opened the tasks manager of Windows 10, found that the memory footprint was up to 96%. I tried to close ST4, but found it still there and I can't close it manually. In about half a minute, it's gone from the process list, and my memory footprint fall down. At one point the memory footprint dropped to 37%, after I restart ST4, the memory footprint stable in the 50s%.

Expected behavior

Actual behavior

Environment

deathaxe commented 3 years ago

ST executable uses 3.6MB RAM in your first screenshot. That's not very much.

If RAM drops after closing ST, it may be the plugin_host which uses all the RAM. It's unfortunatelly not listed in your screenshot.

This normally indicates a plugin running out of control.

wbond commented 3 years ago

I should note, 147MB of memory would be pretty typical for having a folder open and having used a handful of syntax definitions for editing a couple of different types of files.

There are a handful of things that we allocate memory for when they are first used, and we keep them around rather than dumping them, reclaiming the memory and reallocating in the future.

IMO, memory usage under 500MB while using the program is probably typical for a smaller projects, and big projects may use 500MB-1GB. The number of plugins and what they do will also affect this number.

deathaxe commented 3 years ago

Agree,

Just note the overall RAM usage of the first screenshot. Windows already tried to free as much RAM as possible hence ST executable uses 3.6MB only. Another process not displayed in the screenshot seems to eat all RAM.

The 2nd screenshot with 150MB being used is quite normal. Overall RAM usage is only 56% then.

absop commented 3 years ago

I just ran into this again. My system's total memory usage was up to 87%, and the task manager showed that ST was using about 160MB of memory (the sum of the two plugin_hosts and one ST window). When I shut down ST for over half a minute, the memory usage dropped to around 60%. I will provide the recording screen and more information later.

I first noticed this when I saw in the Windows10 Task Manager that my overall system memory usage was up to 96%, but I couldn't find any programs in the list of processes that were specifically using memory. I was wondering where all my memory was. When I turned off ST4, the memory usage dropped by more than 40%. (My guess is that, when the overall memory usage of Windows reaches a certain point, many applications will have their original memory squeezed back, so when it get to 95%, the drop is bigger than what i see today)

To my curiosity, after I opened ST4 for long time, the memory usage of ST4 in the task manager was roughly the same as when I opened it, but the overall system memory usage had gone up a lot; After I turned ST4 off, memory usage dropped by tens of percent. I think the memory used by plugins has been added to the total memory used by ST, so I report this issue.

I used two plugins I wrote myself, one for Scheme syntax highlighting and the other is RainbowBrackets (using only simple Python and ST interface). They all work fine on ST3, but on ST4, because the regions added through the add_regions API are rendered unsteadily, regions of bracket characters are not well rendered. But I don't think it's the two plugins that caused the problem.

112965174-97e05b00-917b-11eb-876b-ef0b462bf2f5

image

absop commented 3 years ago

I just ran into this again. My system's total memory usage was up to 87%, and the task manager showed that ST was using about 160MB of memory (the sum of the two plugin_hosts and one ST window). When I shut down ST for over half a minute, the memory usage dropped to around 60%. I will provide the recording screen and more information later.

I first noticed this when I saw in the Windows10 Task Manager that my overall system memory usage was up to 96%, but I couldn't find any programs in the list of processes that were specifically using memory. I was wondering where all my memory was. When I turned off ST4, the memory usage dropped by more than 40%. (My guess is that, when the overall memory usage of Windows reaches a certain point, many applications will have their original memory squeezed back, so when it get to 95%, the drop is bigger than what i see today)

To my curiosity, after I opened ST4 for long time, the memory usage of ST4 in the task manager was roughly the same as when I opened it, but the overall system memory usage had gone up a lot; After I turned ST4 off, memory usage dropped by tens of percent. I think the memory used by plugins has been added to the total memory used by ST, so I report this issue.

I used two plugins I wrote myself, one for Scheme syntax highlighting and the other is RainbowBrackets (using only simple Python and ST interface). They all work fine on ST3, but on ST4, because the regions added through the add_regions API are rendered unsteadily, regions of bracket characters are not well rendered. But I don't think it's the two plugins that caused the problem.

112965174-97e05b00-917b-11eb-876b-ef0b462bf2f5

image

As a side note, my system has a total memory size of 8GB.

TerminalFi commented 3 years ago

@absop Start sublime in safe mode and see if you get the same behavior. If you don't then it is likely a plugin issue.

absop commented 3 years ago

Yes, It's public.

zlang0

@. | 签名由网易邮箱大师定制 On 4/20/2021 @.> wrote:

@absop Are the plugins you create public? Can we test them to see if the results are the same?

Also start sublime in safe mode and see if you get the same behavior. If you don't then it is likely a plugin issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

absop commented 3 years ago

What I now find is that after I startup ST4 for a long time, the system memory runs out. For example, last night I left ST4 on and went to sleep. At that time, the system memory utilization was normal, probably around 50 percent. Then today I woke up, opened the task manager, and found that the memory utilization rate reached 96%, so I recorded a video recording the memory utilization rate during the process of shutting down ST4. Here is the video screen, and it's about 1.5 minutes long.

new2

Because GitHub has a maximum limit of 10M for uploading GIF, I tried several times to record this video successfully. During the recording process, I tried to keep still to reduce the information content of the video and thus reduce its size. @wbond @deathaxe @TheSecEng @titoBouzout

absop commented 3 years ago

What I now find is that after I startup ST4 for a long time, the system memory runs out. For example, last night I left ST4 on and went to sleep. At that time, the system memory utilization was normal, probably around 50 percent. Then today I woke up, opened the task manager, and found that the memory utilization rate reached 96%, so I recorded a video recording the memory utilization rate during the process of shutting down ST4. Here is the video screen, and it's about 1.5 minutes long.

new2

Because GitHub has a maximum limit of 10M for uploading GIF, I tried several times to record this video successfully. During the recording process, I tried to keep still to reduce the information content of the video and thus reduce its size. @wbond @deathaxe @TheSecEng @titoBouzout

About that screen recording, at the beginning, I tried to close ST4, then I scrolled down to find the remained process of ST4, waited there until the remained process exit completely.

I can't find any processes in the process list that have very high memory usage, it's just that the total memory usage of the system has reached a very high level, so I think there was a memory leak.

deathaxe commented 3 years ago

Up to this point I always was able to find a certain process eating all the RAM.

The process being busy while stopping may be normal due to high memory utilization blocking functions, but what I find strange is the GPU to use 10% constantly all the time. I know Windows to use hardware accelaration to do certain rendering stuff even if applications itself use "software rendering". May ST trigger a driver bug or something like that?

Could you try to leave the same folder/files open over night with ST running in SAFE MODE just to make sure the issue not to be triggered by any plugin?

Otherwise a list of installed packages and maybe settings could provide some information.

TerminalFi commented 3 years ago

Up to this point I always was able to find a certain process eating all the RAM.

The process being busy while stopping may be normal due to high memory utilization blocking functions, but what I find strange is the GPU to use 10% constantly all the time. I know Windows to use hardware accelaration to do certain rendering stuff even if applications itself use "software rendering". May ST trigger a driver bug or something like that?

Could you try to leave the same folder/files open over night with ST running in SAFE MODE just to make sure the issue not to be triggered by any plugin?

Otherwise a list of installed packages and maybe settings could provide some information.

When doing this, don't install any plugins also. Let it be a fully clean run in safe mode

absop commented 3 years ago

Up to this point I always was able to find a certain process eating all the RAM. The process being busy while stopping may be normal due to high memory utilization blocking functions, but what I find strange is the GPU to use 10% constantly all the time. I know Windows to use hardware accelaration to do certain rendering stuff even if applications itself use "software rendering". May ST trigger a driver bug or something like that? Could you try to leave the same folder/files open over night with ST running in SAFE MODE just to make sure the issue not to be triggered by any plugin? Otherwise a list of installed packages and maybe settings could provide some information.

When doing this, don't install any plugins also. Let it be a fully clean run in safe mode

OK, I'll try it. Can I just open ST with SAFE MODE, and open the same project?

TerminalFi commented 3 years ago

Up to this point I always was able to find a certain process eating all the RAM. The process being busy while stopping may be normal due to high memory utilization blocking functions, but what I find strange is the GPU to use 10% constantly all the time. I know Windows to use hardware accelaration to do certain rendering stuff even if applications itself use "software rendering". May ST trigger a driver bug or something like that? Could you try to leave the same folder/files open over night with ST running in SAFE MODE just to make sure the issue not to be triggered by any plugin? Otherwise a list of installed packages and maybe settings could provide some information.

When doing this, don't install any plugins also. Let it be a fully clean run in safe mode

OK, I'll try it. Can I just open ST with SAFE MODE, and open the same project?

Yes, this would be correct

absop commented 3 years ago

Up to this point I always was able to find a certain process eating all the RAM. The process being busy while stopping may be normal due to high memory utilization blocking functions, but what I find strange is the GPU to use 10% constantly all the time. I know Windows to use hardware accelaration to do certain rendering stuff even if applications itself use "software rendering". May ST trigger a driver bug or something like that? Could you try to leave the same folder/files open over night with ST running in SAFE MODE just to make sure the issue not to be triggered by any plugin? Otherwise a list of installed packages and maybe settings could provide some information.

When doing this, don't install any plugins also. Let it be a fully clean run in safe mode

OK, I'll try it. Can I just open ST with SAFE MODE, and open the same project?

Yes, this would be correct

Okay, I'll give you a feedback tomorrow.

deathaxe commented 3 years ago

I don't think it is required to quote everything in each answer post.

absop commented 3 years ago

The GPU is used by my screen recording software. @deathaxe

absop commented 3 years ago

I just ran ST in SAFE MODE overnight without installing any plugins and changing any settings. This is my new screen record of turning off ST, which shows that, even in SAFE MODE, a blank ST causes RAM to be slowly run out over time.

new1

absop commented 3 years ago

There is no extra settings in my project except

{
    "settings": {
        "LSP": {
            "clangd": {
                "enabled": false,
            },
            "haskell-language-server": {
                "enabled": false,
            },
        },
    }
}

but I didn't install any plugins even Package Control, so these settings are meaningless.

I wonder if anyone has reproduced what I have met. My project is directly continuation using of the previous ST3 project. I don't know whether the problem is caused by the incompatibility of the project workspace.

Or maybe I need to keep ST running in SAFE MODE again tonight, without opening any files and folders, to get more information?

deathaxe commented 3 years ago

So that's pretty clearly some core bug. Quite subtile as the process itself doesn't show the RAM usage. I could try to reproduce it but the only info I could provide was wether it happens or not.

BarabasGitHub commented 3 years ago

I think this is the same as I just reported (sorry, didn't check for existing issues before).

4122

The memory usage comes from the non-paged pool usage.

deathaxe commented 3 years ago

It's the same issue as https://github.com/sublimehq/sublime_text/issues/4122