vscode-ltex icon indicating copy to clipboard operation
vscode-ltex copied to clipboard

vscode-ltex leaves a stray java process behind

Open pjssilva opened this issue 2 years ago • 37 comments

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. 2. Await a few minutes for ltex to start. 3. Close the editor. 4. 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.

\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.

  • Operating system: Linux (linux), x64, 5.13.0-22-generic
  • VS Code: 1.63.2
  • vscode-ltex: 13.1.0
  • ltex-ls: 15.2.0
  • Java: 11.0.12

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

pjssilva avatar Dec 24 '21 12:12 pjssilva

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

kozyakin avatar Jan 04 '22 01:01 kozyakin

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

NVfly avatar Jan 04 '22 16:01 NVfly

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.

ogmios-voice avatar Jan 17 '22 11:01 ogmios-voice

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

meneguzzi avatar Jan 17 '22 16:01 meneguzzi

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)

daniporr avatar May 05 '22 13:05 daniporr

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.

yutotakano avatar May 05 '22 20:05 yutotakano

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

daniporr avatar May 06 '22 13:05 daniporr

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?

dmitry-kabanov avatar May 18 '22 21:05 dmitry-kabanov

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 avatar Aug 24 '22 04:08 unional

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

There is no deactivate function defined.

unional avatar Aug 24 '22 04:08 unional

Any news on this?

daniporr avatar Oct 09 '22 11:10 daniporr

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.

mtsknn avatar Oct 20 '22 09:10 mtsknn

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

I still have it.

daniporr avatar Jan 14 '23 19:01 daniporr

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

kaiwu-astro avatar Feb 15 '23 06:02 kaiwu-astro

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.

testMonkey02 avatar Apr 03 '23 14:04 testMonkey02

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...

meneguzzi avatar Apr 03 '23 14:04 meneguzzi

I can confirm this issue is present on openSUSE Tumbleweed

fportales avatar May 05 '23 22:05 fportales

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

LordDover avatar Jun 19 '23 14:06 LordDover

@valentjn any news on this?

daniporr avatar Jun 19 '23 20:06 daniporr

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.

j-lakeman avatar Sep 07 '23 06:09 j-lakeman

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

fdamore95 avatar Oct 30 '23 13:10 fdamore95

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

Hecatron avatar Nov 15 '23 00:11 Hecatron

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

daniporr avatar Nov 19 '23 15:11 daniporr

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

  • https://github.com/streetsidesoftware/vscode-spell-checker

Hecatron avatar Nov 19 '23 16:11 Hecatron

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

  • https://github.com/streetsidesoftware/vscode-spell-checker

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

daniporr avatar Nov 19 '23 18:11 daniporr

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

  • https://github.com/streetsidesoftware/vscode-spell-checker

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

Hecatron avatar Nov 19 '23 21:11 Hecatron

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?

daniporr avatar Dec 06 '23 18:12 daniporr

@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...

briochemc avatar Dec 20 '23 23:12 briochemc

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.

meneguzzi avatar Dec 22 '23 14:12 meneguzzi

@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.

unional avatar Dec 24 '23 01:12 unional