valentjn / vscode-ltex

LTeX: Grammar/spell checker :mag::heavy_check_mark: for VS Code using LanguageTool with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
784 stars 26 forks source link

vscode-ltex leaves a stray java process behind #497

Open pjssilva opened 2 years ago

pjssilva commented 2 years ago

Enter a summary of the issue in the title field above and replace this sentence with the bug report from your clipboard.

Describe the bug When I use vscode-ltex it leaves a stray java process behind even after I close the editor.

Steps to reproduce Steps to reproduce the behavior:

1.Open any LaTeX document in vscode with ltex installed.

  1. Await a few minutes for ltex to start.
  2. Close the editor.
  3. Search for "java" in your process list. There will be a stray java process running and consuming memory;

Expected behavior I would expect all java processes started by vscode-ltex to terminate upon closing vscode.

Sample document Any document will do, see the example below.

```latex \documentclass{article} \begin{document} Any document will do. \end{document} ```

LTeX configuration Please paste all configuration settings starting with ltex. from your settings.json. You can help us by temporarily removing some irrelevant settings from your settings.json and see if the bug still occurs.

``` { "enabled": [ "bibtex", "context", "context.tex", "html", "latex", "markdown", "org", "restructuredtext", "rsweave" ], "language": "en-US", "dictionary": {}, "disabledRules": {}, "enabledRules": {}, "hiddenFalsePositives": {}, "bibtex": { "fields": {} }, "latex": { "commands": {}, "environments": {} }, "markdown": { "nodes": {} }, "configurationTarget": { "dictionary": "workspaceFolderExternalFile", "disabledRules": "workspaceFolderExternalFile", "hiddenFalsePositives": "workspaceFolderExternalFile" }, "additionalRules": { "enablePickyRules": false, "motherTongue": "", "languageModel": "", "neuralNetworkModel": "", "word2VecModel": "" }, "languageToolHttpServerUri": "", "languageToolOrg": { "username": "", "apiKey": "" }, "ltex-ls": { "path": "", "logLevel": "fine", "languageToolHttpServerUri": "", "languageToolOrgUsername": "", "languageToolOrgApiKey": "" }, "java": { "path": "", "initialHeapSize": 64, "maximumHeapSize": 512 }, "sentenceCacheSize": 2000, "completionEnabled": false, "diagnosticSeverity": "information", "checkFrequency": "edit", "clearDiagnosticsWhenClosingFile": true, "statusBarItem": false, "trace": { "server": "off" } } ```

"LTeX Language Server" log file First, reproduce the bug. Then, go to ViewOutput and select LTeX Language Server in the drop-down list. Paste this log here:

``` [Info - 09:33:41] Starting ltex-ls... dez 24, 2021 9:33:47 AM org.bsplines.ltexls.server.LtexLanguageServer initialize INFORMAÇÕES: ltex-ls 15.2.0 - initializing... dez 24, 2021 9:33:47 AM org.bsplines.ltexls.tools.I18n setLocale INFORMAÇÕES: Setting locale to 'en' dez 24, 2021 9:33:48 AM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked DETALHADO: Checking the following text in language 'en-US' via LanguageTool: "\n\n\n\nAny document will do.\n\n" dez 24, 2021 9:33:51 AM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment DETALHADO: Obtained 0 rule matches ```

"LTeX Language Client" log file First, set the ltex.trace.server setting in your settings.json to "verbose". Then, reload the VS Code window and reproduce the bug. Go to ViewOutput and select LTeX Language Client in the drop-down list. Paste this log here (note: it will contain your checked document):

``` 2021-12-24T12:33:40.423Z Info: Setting LTeX UI language to 'pt-br'. 2021-12-24T12:33:40.423Z Info: Loading i18n messages... 2021-12-24T12:33:40.424Z Info: Loading default i18n messages... 2021-12-24T12:33:40.428Z Info: 2021-12-24T12:33:40.428Z Info: ltex.ltex-ls.path not set. 2021-12-24T12:33:40.428Z Info: Searching for ltex-ls in '/home/pjssilva/.vscode/extensions/valentjn.vscode-ltex-13.1.0/lib'... 2021-12-24T12:33:40.429Z Info: ltex-ls found in '/home/pjssilva/.vscode/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0'. 2021-12-24T12:33:40.429Z Info: 2021-12-24T12:33:40.429Z Info: Using ltex-ls from '/home/pjssilva/.vscode/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0'. 2021-12-24T12:33:40.429Z Info: Using Java bundled with ltex-ls as ltex.java.path is not set. 2021-12-24T12:33:40.445Z Info: Testing ltex-ls... 2021-12-24T12:33:40.445Z Info: Command: "/home/pjssilva/.vscode/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0/bin/ltex-ls" 2021-12-24T12:33:40.445Z Info: Arguments: ["--version"] 2021-12-24T12:33:40.445Z Info: env['JAVA_HOME']: undefined 2021-12-24T12:33:40.445Z Info: env['JAVA_OPTS']: "-Xms64m -Xmx512m" 2021-12-24T12:33:41.723Z Info: Test successful! 2021-12-24T12:33:41.733Z Info: 2021-12-24T12:33:41.737Z Info: Starting ltex-ls... 2021-12-24T12:33:41.737Z Info: Command: "/home/pjssilva/.vscode/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0/bin/ltex-ls" 2021-12-24T12:33:41.737Z Info: Arguments: [] 2021-12-24T12:33:41.737Z Info: env['JAVA_HOME']: undefined 2021-12-24T12:33:41.737Z Info: env['JAVA_OPTS']: "-Xms64m -Xmx512m" 2021-12-24T12:33:41.737Z Info: 2021-12-24T12:33:57.138Z Info: Creating bug report... ```

Version information List here the version information of the relevant software.

Additional context/information You can add any other context or information about the problem here.

kozyakin commented 2 years ago

Confirm the issue both on MacOS and Windows 10 with Microsoft OpenJDK 17 installed

NVfly commented 2 years ago

I have same issue both on intel Mac and M1 Mac.

ogmios-voice commented 2 years ago

Another way to reproduce it:

  1. Open (a larger?) document
  2. Enable LTeX vscode extension / Start spell check
  3. Disable LTeX vscode extension
  4. Reload (select Reload Required)

In case of a larger file, the LTeX-LS java process will still be consuming the CPU.

meneguzzi commented 2 years ago

I confirm this on my Mac. This seems to happen more when you have Markdown files open.

daniporr commented 2 years ago

I confirm that this issue exists on different versions of Windows and on different versions of Linux.

P.S. why does this issue have the 2-unconfirmed label? (several people have confirmed this issue now)

yutotakano commented 2 years ago

Definitely an issue, yes. (This is after all VSCode has been quit). I didn't realise it was from LTex since the macOS Activity Monitor only says "java" (with parent process being launchd):

image

However, upon checking with ps, I confirm too that they are all LTex language server processes that have accumulated over time:

image

I thought maybe https://github.com/valentjn/ltex-ls/issues/117 might be related (similar issue, and popped up around similar time last year), but it seems that's already closed so I don't know.

daniporr commented 2 years ago

I thought maybe valentjn/ltex-ls#117 might be related (similar issue, and popped up around similar time last year), but it seems that's already closed so I don't know.

It is worth noting that it does with both OpenJDK and the "official" (Oracle) one

dmitry-kabanov commented 2 years ago

This bug affects me also. I have an M1 Macbook with 8 Gb of memory, and when I close different apps to free up the memory, I can see this leftover java process after closing VSCode.

It says here: https://github.com/microsoft/vscode-jupyter/issues/1626#issuecomment-631581750

that they give 5 seconds to processes to shutdown when VSCode exits. Can it be that ltex does not shutdown within these 5 seconds?

unional commented 2 years ago

This is close to a deal breaker. It leaves a java.exe running for every instance vscode opened.

Depends on the side of the project, they can consume north of 1GB+ of memory.

that they give 5 seconds to processes to shutdown when VSCode exits. Can it be that ltex does not shutdown within these 5 seconds? Some of the projects I test are extremely light. My guess the extension just didn't kill the process.

unional commented 2 years ago

https://github.com/valentjn/vscode-ltex/blob/develop/src/extension.ts

There is no deactivate function defined.

daniporr commented 1 year ago

Any news on this?

mtsknn commented 1 year ago

I had this problem some months ago on my Mac, but not anymore. Anyone else not experiencing this anymore?

The latest (non-pre-release) version of LTeX was published in Nov 2021 (see releases), and I first installed LTeX in Feb 2022, so maybe the problem disappeared by updating VS Code to a certain version.

daniporr commented 1 year ago

I had this problem some months ago on my Mac, but not anymore. Anyone else not experiencing this anymore?

I still have it.

kaiwu-astro commented 1 year ago

I am experiencing the same problem on Linux. The poor machine's memory was full of LTeX 😂

I use VSCode on mac, but through remote-development to an Ubuntu 16.04 machine. On the Ubuntu machine I have vscode server and LTeX installed.

Everyday when I leave my office, I shutdown all VSCode windows on my mac, but LTeX process with Java does not exit.

Next day I open all VSCode windows again, another LTeX process will be created.

As a result, yesterday I found my Ubuntu machine memory almost full, and there was over 20 LTeX running. I had to kill all of them manually.

I don't know if it's a cross-platform problem, or it's just with VSCode client on mac, or *nix

============== Quite easy to re-produce. Just re-open all VSCode windows, and then more LTeX processes come

iShot_2023-02-15_15 45 32
testMonkey02 commented 1 year ago

I still have the problem on my MacBook pro M1 MacOS Monterey 12.6.3. And another related problem is the java causes high CPU and memory overhead, even the fan of my mac are spinning, which you know the fan of MacBook pro M1 is very hard to activate. This exists even after I quit VSCode.

meneguzzi commented 1 year ago

I thought this problem went away at some point, but recently, it's back. My current workaround is to periodically run:

pkill -f extensions/valentjn.vscode-ltex

Though of course that is not quite ideal...

fportales commented 1 year ago

I can confirm this issue is present on openSUSE Tumbleweed

LordDover commented 1 year ago

I'm getting this issue too. MacOS 13.3.1 on an x86 machine.

daniporr commented 1 year ago

@valentjn any news on this?

j-lakeman commented 1 year ago

I am mostly experiencing this on macOS. I think my Linux machines are ending potentially left java processes themselves (probably systemd cleaning up orphans). Using the bundled binaries on both Linux and macOS atm.

fdamore95 commented 10 months ago

Same issue here. These processes eat quite a lot of memory. Screenshot from 2023-10-30 15-49-55

Hecatron commented 10 months ago

I'm noticing after opening vscode with a markdown file ltex is leaving stray processes open on windows 10 after vscode is closed every time now

image

daniporr commented 9 months ago

Is anyone able to fix this problem and open a PR for it? (unfortunately I am not)

Hecatron commented 9 months ago

Switching to code spell checker seems to be the only option at the moment

daniporr commented 9 months ago

Switching to code spell checker seems to be the only option at the moment

Unfortunately, this is "A simple source code spell checker for code" and it doesn't use LanguageTool.

Hecatron commented 9 months ago

Switching to code spell checker seems to be the only option at the moment

Unfortunately, this is "A simple source code spell checker for code" and it doesn't use LanguageTool.

It does work with markdown files at least, but I admit its not as good as it doesn't cover grammer

daniporr commented 9 months ago

It does work with markdown files at least, but I admit its not as good as it doesn't cover grammer

"LanguageTool" is a "multilingual spelling, style, and grammar checker" while "Spelling Checker for Visual Studio Code" is a "A simple source code spell checker for code" [definitions from their respective websites]

They are completely different tools (used for different purposes)

But we should stop going off topic here. This issue is about the Java processes that keep running after you close VS Code. Is anyone able to fix this problem and open a PR for it?

briochemc commented 8 months ago

@daniporr I agree with you but, even if someone submitted a PR to fix this (which https://github.com/valentjn/vscode-ltex/pull/758 maybe already does, right? @nicholas-l), I would not hold my breath for it to be reviewed/merged, given that the last merged PR is about 2 years old now. Maybe @nicholas-l's fork is the way to go? Although I'm not sure how to use a fork in VSCode...

meneguzzi commented 8 months ago

Well, can he not just create a new extension based on the fork? There are loads of extensions based off of a fork. Depending on the license on this repo, this should be perfectly doable. Hell, given how many people work on this, it might make sense to create an org in Github and turn this to the community, since there seems to be loads of people interested.

I know I'd try to help to the extent I have time to.

unional commented 8 months ago

@nicholas-l are you interested in publishing a fork one based on your changes? Your PR looks reasonable. I can work with you on it if you are interested.

daniporr commented 8 months ago

@briochemc @meneguzzi @unional thank you for sharing these wonderful ideas!

Since this extension is based on another project of @valentjn (ltex-ls), and since there are commits from the beginning of this year (in both projects) I think we should give @valentjn the chance to rebut if

  1. this project is still maintained
  2. they want to add other maintainers
  3. they want to transfer it to an organisation account where multiple people can contribute collectively to it

@valentjn do you have any answers to these points?

Note that this (especially, 3.) will simplify the whole process

unional commented 8 months ago

Hi @valentjn please let us know if you are active or want to continue to maintain these repos.

In the mean time, I have created https://github.com/neo-ltex for publishing the fix.

Anyone who would like to contribute please feel free to drop a note.

meneguzzi commented 8 months ago

Hi, is there a corresponding extension in the VSCode Marketplace @unional?

unional commented 8 months ago

https://marketplace.visualstudio.com/items?itemName=neo-ltex.ltex

Releasing 13.1.1 which fixes this issue.

It's still in early stage as I'm keeping most of the code identical. So many links and references are likely off.

There are also quite a few things to change to improve the DX before the code can be cleaned up.

meneguzzi commented 8 months ago

Ok, so let's move part of this discussion to the new repo. I'm short of time in the next two weeks, but I will try to pitch in as soon as possible.

nicholas-l commented 7 months ago

@nicholas-l are you interested in publishing a fork one based on your changes? Your PR looks reasonable. I can work with you on it if you are interested.

Sorry I missed this. I was hoping that we could merge the fixes into this repo but looks like its unmaintained now. The new repo looks good, great work getting updating all the dependencies @unional . I'll have a go at using the new extension.

unional commented 7 months ago

I'll have a go at using the new extension.

@nicholas-l the new extension contains your fix.

I'm gradually updating the development environment to make it easier to work with. After that, will see if we can get some low hanging food added to the extension.