microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.44k stars 1.53k forks source link

/tmp/edg0_# Files Still Taking Up Memory #12288

Closed Alkaid-Benetnash closed 3 weeks ago

Alkaid-Benetnash commented 3 months ago

Environment

"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 https://github.com/microsoft/vscode-cpptools/issues/3633#issuecomment-523682322 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_
sean-mcmanus commented 3 months ago

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

Alkaid-Benetnash commented 3 months ago

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.

brozek commented 2 months ago

Same issue, using VSCode remote/SSH with Windows10 local / Redhat Linux (7.x & 8.x) remote. /tmp directory on remote Linux server fills with edg0_XXXX files which are not removed when the local VSCode instance is stopped.

COMMAND     PID    USER   FD   TYPE DEVICE   SIZE/OFF NODE NAME
cpptools-  6287  brozek  DEL    REG  253,4             535 /tmp/edg0_6287
cpptools-  6287  brozek   11u   REG  253,4 1335726081  535 /tmp/edg0_6287 (deleted)
github-actions[bot] commented 3 weeks ago

This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.