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

Possible memory leak related to `lldb-mi`

Open hackroid opened this issue 4 years ago • 8 comments

Environment

  • OS and version: macOS Ventura 13.0.1 (22A400)
  • VS Code:
    • Version: 1.73.1
    • Commit: 6261075646f055b99068d3688932416f2346dd3b
    • Date: 2022-11-09T02:22:48.959Z
    • Electron: 19.0.17
    • Chromium: 102.0.5005.167
    • Node.js: 16.14.2
    • V8: 10.2.154.15-electron.0
    • OS: Darwin arm64 22.1.0
    • Sandboxed: No
  • C/C++ extension: v1.12.4
  • GDB / LLDB version: lldb-1400.0.38.13, Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)

Bug Summary and Steps to Reproduce

Bug Summary: lldb-mi kept eating memory (about +500MB/s) when debugging until the whole macOS froze.

Steps to reproduce:

  1. Debug the following snippet with the provided environment above
    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    int main()
    {
        vector<int> nn(4, 0);
        for (size_t i = 0; i < 4; i++) {
            int tt;
            cin >> tt;
            nn[i] = tt;
        }
        vector<int> k;
        cout << nn[1];
        return 0;
    }
    
  2. With the config(launch/task) provided below
  3. Make a break point at line 14: vector<int> k;
  4. Start debugging
  5. Input 4 integers 5 2 6 1 , press enter, then be like this debug
  6. Variables monitor will show nothing but loading... var
  7. Open Activity Monitor (macOS app), lldb-mi start using lots of memory act
  8. Stop debugging, close the terminal windows, lldb-mi still won't stop and keep eating memory
  9. Can stop lldb-mi only by force quit.

Debugger Configurations

{
    "configurations": [
        {
            "name": "clang++ dbg",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb",
            "preLaunchTask": "C/C++: clang++ build active file",
            "logging": { "engineLogging": true, "trace": true, "traceResponse": true }
        }
    ],
    "version": "2.0.0"
}

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

Debugger Logs

https://blog.hackroid.com/debug-log.html

Other Extensions

No response

Additional Information

No response

hackroid avatar Nov 21 '22 12:11 hackroid

Small changes to the code will avoid the problem, but, just wondering why. Like: line 10: move int tt; outside the for loop. Or like: line 9: change size_t to int.

hackroid avatar Nov 21 '22 14:11 hackroid

It's broken. I switched to CodeLLDB for debugging on macOS.

https://github.com/microsoft/vscode-cpptools/issues/9831

H-G-Hristov avatar Nov 22 '22 18:11 H-G-Hristov

@WardenGnaw have you seen this?

bobbrow avatar Nov 23 '22 16:11 bobbrow

Yeah, this is due to the external dependency the debugger uses lldb-mi.

WardenGnaw avatar Nov 28 '22 18:11 WardenGnaw

Observed the exact same issue, i.e., local variable keep loading, lldb-mi showing significant memory consumption after a while.

OS

macOS Ventura Version 13.2.1 (22D68)

VSCode

Version: 1.76.2 Commit: ee2b180d582a7f601fa6ecfdad8d9fd269ab1884 Date: 2023-03-14T17:53:46.528Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Darwin arm64 22.3.0 Sandboxed: No

zanmato1984 avatar Mar 30 '23 06:03 zanmato1984

It's broken. I switched to CodeLLDB for debugging on macOS.

#9831

This works for me too. Thanks bro!

zanmato1984 avatar Mar 30 '23 09:03 zanmato1984

Same issue when trying to step through a googletest test case that involves popen(). Stepping through any other code is smooth and leak-free.

denniskb avatar Jul 27 '24 07:07 denniskb

macOS 15.2 Beta (24C5089c), Version: 1.95.3 (Universal) Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813 Date: 2024-11-13T14:50:04.152Z (1 wk ago) Electron: 32.2.1 ElectronBuildId: 10427718 Chromium: 128.0.6613.186 Node.js: 20.18.0 V8: 12.8.374.38-electron.0 OS: Darwin arm64 24.2.0 Same problemImage 80G of memory is crazy, luckily it won't completely froze my system thanks to swap

feiyehua avatar Nov 25 '24 09:11 feiyehua