-
Notifications
You must be signed in to change notification settings - Fork 53
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
TexLab consumes all the memory #856
Comments
Also, I would like to note, that even on v4.3.2 I notice a big bump in the memory consumption after switching the window focus, to around 3.75 GiB, but it stops there. |
@jakubkaczor It looks like |
@pfoerster, sure. Here is the output. |
@jakubkaczor Sorry the long wait. The log file looks very odd. First of all, it looks like
Can you try increasing the verbosity level and see if Neovim reports something? |
One thing I thought may be obvious, but it wasn't: do you expect me to send the log generated with the latest release, latest main, or the commit I firstly experienced the issue with? I assumed the latter and now, when I compile it, I can see a warning that may be related.
In Neovim configuration I set the running command as cmd = {"texlab", "-vvvv", "--log-file=/tmp/texlab.log"} As the file is written, I assume the change was effective, and the verbosity level is as desired. I additionally set NeoVim's LSP log level to trace (the most verbose), and now in |
@jakubkaczor Thank you for providing the log file.
It looks like Sorry to ask about your directory structure, but
I think it is more helpful to look at the latest release instead of f0d3996. The server has changed a lot internally in the mean time. |
Hi There, I'm having the same problem. (I don't know if I can trace it to switching windows.) But when I start off texlab's memory footprint is negligible. After about 20 mins of editing it's climbed to 1.5GB of my system memory. After a long editing session yesterday I noticed texlab was up to 4GB+ of memory usage. I'd be happy to give you more info (e.g. output of Any suggestions? GI |
I just checked that I still have this issue with 5.4.0. As a temporary work-around, I got my editor to restart texlab periodically. If anyone else uses local on_attach = function( client, bufnr )
-- vim.keymap.set(...) and other LSP settings
-- Kill in texlab periodically to avoid memory leak bug
if client.name == 'texlab' then
vim.defer_fn( function ()
if vim.api.nvim_get_current_buf() == bufnr then
vim.cmd('LspRestart')
else
client.stop()
print( 'Stopped TexLab' )
end
end, 10*60*1000 )
end
end and pass it to the setup function in your LSP config. |
Unfortunately, I am not that familiar with Neovim but you need a way to bind the @gi1242 Can you tell me more about the editing session? Does the RAM usage also increase if you are only editing the same files over and over or are you switching between different files/projects? |
I'm editing the same file only (not switching files, or projects). The issue always happens on my system. Periodically killing texlab (like I did above) makes it somewhat usable (sometimes I also have to quit the editor and restart). But at least now my system isn't freezing due to lack of memory :). I will try and figure out how to run |
OK, I may have something useful: I ran
Now I go about editing as usual (same file, same setup). I notice that texlab doesn't get killed. (If it uses more than 500M memory, it will automatically get killed.) My guess is that texlab was aggressively caching something (or there was some garbage collection issue), and it felt comfortable taking up my 8GB RAM + 16 GB swap. (When texlab reached 4GB my system was constantly swapping and really slow.) I'll post back in a few days if I can confirm it's stable. |
Yeah, I think the syntax trees built from the related files are an issue here. Currently, |
I'm sorry I won't be able to dig into it deeper this week. In NeoVim configuration file for the server we have a function determining the root directory. When one of the conditions in the body is satisfied, that is, I have |
Thank you so much. If it helps: the file I've been noticing issues with is about 200kb (3500 lines). The associated .bib file has about 10,000 entries. I was working on smaller files on systems with more memory before and never had any issues. Probably because texlab wasn't using enough memory to make my system swap... |
Can you try out #875, please? It should help when switching between different, unrelated projects. |
OK, I tried it. I was having the trouble even without switching files before; so I tried it on the same file. The memory growth is more managable, but still present. Now when I'm not doing anything, the memory doesn't grow. The more I type the more the memory grows. If I ask it to complete refs and citations from a large file I can quickly get the memory usage up to some 1.5GB. I'll use it (without a memory quota) for the next week or so and report back. |
I've been investigating a bit myself on macOS and I cannot quite reproduce this memory growth (with a modest ~450 page project) -- asking for references or citation completion adds a few megabytes of memory, at most, and just typing doesn't change much; the memory usage remains at 100-200MB. The biggest jump comes from citations, so this:
is almost certainly the culprit. Is this a local bib file, or something in your global personal In any case, citation handling looks to be the place to look at for possible optimizations. |
OK, I've been using it for a bit now and the behavior seems consistent: After a long editing session the memory usage climbs to a little less than 1GB. It doesn't seem to increase beyond that (unllike before where it would grow without bound, even when I wasn't using vim). Memory only grows when I type. So it's manageable... but probably not ideal. (It's the single highest memory user on my system now; more than firefox, which has some 20 tabs open) If you think the bib file is the culprit, I'm attaching it. (I know you don't like global bib's, but using this (and If you can reproduce the memory growth, then we have confirmation. |
Same issue In ArchLinux and neovim
Is it possible that the problem is related to the operation system? Just a guess |
If it helps I have same issue on ArchLinux (EndeavourOS) using doom emacs. Texlab can reach 8GB on large documents or when writing for about 4hours. |
I have found the cause of the memory leak and created a PR (#877) which fixes the issue (quite large diff but most of the changes result from crate splitting). Can you try it out, please? The memory usage should be stable now. Previously, it was possible to keep increasing the memory usage by repeatedly sending |
Yeah, there are still some optimizations to be made here. As these large bibliography files rarely change, we can precompute most of the data required to provide completion. Discarding the parse tree and relying on the index instead would also help here. |
I checked. Memory footprint doesn't grow like it used to. (I'll keep using it this week). However, now the old bug about pre-compiled headers in issue #845 seems to have resurfaced. Did that patch get affected (or did I mess up). |
Yes #845 is fixed now. If I see uncontrolled growth in memory, I'll let you know. As of now (even with my large bib files) the memory footprint of texlab is negligible. Thanks a lot for the quick fix. |
Closing this issue for now. Please let me know, if you still encounter a problem. |
## [5.5.0] - 2023-04-16 ### Added - Allow optionally passing cursor position to `textDocument/build` request for use in forward search after building. Previously, the server had to guess the cursor position ([#475](latex-lsp/texlab#475)) - Add experimental `texlab.experimental.citationCommands` setting to allow extending the list of citation commands ([#832](latex-lsp/texlab#832)) - Add support for escaping placeholders in build arguments similar to forward search - Allow configuring completion matching algorithm ([#872](latex-lsp/texlab#872)) ### Fixed - Fix regression introduced in `v5.4.2` involving `texlab.cleanArtifacts` command. ## [5.4.2] - 2023-04-11 ### Fixed - Fix memory leak when editing documents over a long time ([#856](latex-lsp/texlab#856)) - Fix parsing parentheses in file paths ([#874](latex-lsp/texlab#874)) ## [5.4.1] - 2023-03-26 ### Fixed - Do not return symbols with empty names (e. g. sections without name) ([#870](latex-lsp/texlab#870)) - Repair `textDocument/formatting` request ([#871](latex-lsp/texlab#871)) ## [5.4.0] - 2023-03-12 ### Added - Add experimental settings to allow extending the list of special environments: - `texlab.experimental.mathEnvironments` - `texlab.experimental.enumEnvironments` - `texlab.experimental.verbatimEnvironments` - Add `texlab.changeEnvironment` workspace command ([#849](latex-lsp/texlab#849)) - Add `texlab.showDependencyGraph` workspace command ### Changed - Do not show caption or section names in label inlay hints ([#858](latex-lsp/texlab#858)) - Include more user-defined commands in command completion ### Fixed - Parse nested `\iffalse` blocks correctly ([#853](latex-lsp/texlab#853)) - Parse commands with multi-byte characters correctly ([#857](latex-lsp/texlab#857)) - Fix checking whether a document can be a root file ## [5.3.0] - 2023-02-25 ### Added - Allow filtering `textDocument/documentSymbols` using regular expressions specified via `texlab.symbols.allowedPatterns` and `texlab.symbols.ignoredPatterns` ([#851](latex-lsp/texlab#851)) ### Fixed - Do not use percent-encoded path when searching for PDF files during forward search ([#848](latex-lsp/texlab#848)) - Always return an empty list of code actions instead of returning "method not found" ([#850](latex-lsp/texlab#850)) ## [5.2.0] - 2023-01-29 ### Added - Include line numbers in build warnings when available ([#840](latex-lsp/texlab#840)) - Add `none` formatter to `texlab.latexFormatter` and `texlab.bibtexFormatter` options to allow disabling formatting ([#846](latex-lsp/texlab#846)) ### Fixed - Concatenate more than two lines of maximum length in build diagnostics ([#842](latex-lsp/texlab#842)) - Apply the correct range of references to labels when renaming ([#841](latex-lsp/texlab#841)) - Use `document` environment to detect root file instead of `\documentclass` ([#845](latex-lsp/texlab#845)) ## [5.1.0] - 2023-01-21 ### Added - Allow manually overriding the root directory using a `texlabroot`/`.texlabroot` marker file. See the wiki for more information. ([#826](latex-lsp/texlab#826), [#838](latex-lsp/texlab#838)) ### Deprecated - Deprecate `texlab.rootDirectory` setting in favor of `.texlabroot` files ### Fixed - Do not use `.git`, `.chktexrc`, `.latexmkrc` files/directories to determine the root directory ([#826](latex-lsp/texlab#826)) - Fix building documents without an explicit root directory ([#837](latex-lsp/texlab#837)) ## [5.0.0] - 2022-12-29 ### Changed - _BREAKING_: `texlab.rootDirectory` is now used as the folder path from which the compiler is executed relative to the main document. By default it is equal to `"."`. For more information, please visit the wiki. - Improve performance of completion by a huge margin due to a faster filtering method used internally - Do not discover project files beyond the provided workspace folders - Try to guess the root directory by checking for files such as `.latexmkrc` or `Tectonic.toml` if `texlab.rootDirectory` is not set ### Fixed - Update positions of reported build diagnostics when editing the affected line - Do not treat links to files as bidirectional by default. This prevents issues where `texlab` ends up compiling the wrong file in projects with shared files ([#806](latex-lsp/texlab#806), [#757](latex-lsp/texlab#757), [#679](latex-lsp/texlab#679)) - Fix coverage of directories which need to be watched for changes ([#502](latex-lsp/texlab#502), [#491](latex-lsp/texlab#491)) - Resolve links of the `import` package correctly - Use `filterText` of completion items when filtering internally ([#829](latex-lsp/texlab#829)) ## [4.3.2] - 2022-11-20 ### Fixed - Do not try to run the TeX engine on package files and fail the build instead ([#801](latex-lsp/texlab#801)) - Handle URIs with URL-encoded drive letters on Windows ([#802](latex-lsp/texlab#802)) - Parse BibTeX entries with unbalanced quotes correctly ([#809](latex-lsp/texlab#809)) - Provide completion for more acronym commands ([#813](latex-lsp/texlab#813)) - Fix parsing acronym definitions ([#813](latex-lsp/texlab#813)) ## [4.3.1] - 2022-10-22 ### Fixed - Do not crash with a stack overflow when trying to load packages with many internal dependencies ([#793](latex-lsp/texlab#793)) - Normalize drive letters of all document URIs - Fix parsing commands that take file paths as arguments ([#789](latex-lsp/texlab#789)) - Use the correct working directory and command line arguments when calling `latexindent` ([#645](latex-lsp/texlab#645)) - Fix publishing to CTAN ## [4.3.0] - 2022-09-25 ### Added - Add inlay hints for `\label{...}` ([#753](latex-lsp/texlab#753)) ### Fixed - Improve accuracy of the error locations reported by the TeX engine ([#738](latex-lsp/texlab#738)) - Reduce number of false positive errors reported by `texlab` ([#745](latex-lsp/texlab#745))
As in the title, TexLab consumes all the memory. The steps to reproduce are the following.
nvim-lspconfig
automatically runs TexLab and attaches.Then the memory usage of TexLab increases rapidly. Additionaly, when in the same home directory I create a new subdirectory, “cd” into it and then open the file, the same happens, but the increase in memory usage is much slower. That is
I proceeded with git bisection between v5.2.0 (bad) and v4.3.2 (good), and according to this, and if I did everything correctly, f0d3996 is the first bad commit.
I couldn't see anything in NeoVim's
LspLog
, but I didn't increase its verbosity level.The text was updated successfully, but these errors were encountered: