microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

/tmp/edg0_# Files Still Taking Up Memory

Alkaid-Benetnash opened this issue · comments

Environment

  • OS and Version: Arch Linux
  • VS Code Version: 1.89.0
  • C/C++ Extension Version: v1.19.9
  • If using SSH remote, specify OS of remote machine: N/A

"Help->About" copied from VSCode

Version: 1.89.0
Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd
Date: 2024-05-01T02:08:25.066Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Linux x64 6.8.7-arch1-2

Bug Summary and Steps to Reproduce

Bug Summary:
Basically the same as #3633 . A good summary is in #3633 (comment)
Basically there is no way to configure where to store the tmp/edg cache files. And those files can be huge and occupying spaces depending on how the /tmp is mounted.

Steps to reproduce:

  1. Open/Edit C/C++ files, let the language server run.
  2. Run lsof /tmp
  3. Found deleted yet un-closed files occupying a lot of space (consuming memory if /tmp is on tmpfs). Those files are opened by cpptools-srv
  4. Cannot find a configuration in this extension to change those /tmp/edg0_${PID} locations. Note that the C_Cpp.intelliSenseCachePath is not "/tmp", so the edg0 caches are not controlled by this option.

Expected behavior:
Either properly close the deleted/unlinked cache file, or give users an option to use another directory for the edg0 cache.

Another workaround to use mount namespaces to let vscode to use a special /tmp dir. Example:

sudo -E unshare --mount zsh -c "mount --bind ${HOME}/tmp /tmp && su ${USER} -c code "

Configuration and Logs

No customized `c_cpp_properties.json` file.
I do changed a few options to reduce the cache size. This is a workaround not a solution.

    "C_Cpp.references.maxCachedProcesses": 2,
    "C_Cpp.maxCachedProcesses": 2,
    "C_Cpp.intelliSenseCacheSize": 2048,
    "C_Cpp.maxMemory": 2048,
    "C_Cpp.references.maxMemory": 2048,

c_cpp_log_diagnostics.log
c_cpp_language_server_debug.log



### Other Extensions

I don't think this issue is related to other extensions.


### Additional context

_No response_

@Alkaid-Benetnash Those are temp files created by the EDG parser we use. From looking at the code, it looks like you can change the location by setting the TMPDIR environment variable, but I haven't tested that.

Thanks for checking the source code. Is that part open sourced? I tried to figure this out myself but couldn't find the EDG related code.
I can also confirm that the TMPDIR env works. Maybe it is better to let the EDG parser follow the intellisense cache dir config. But I am happy with this answer and it should be a good enough workaround for other users who come across this issue.

Feel free to close this.