microsoft / vscode-cpptools

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

cpptools-srv allocating 8Gb of RAM right after starting #9144

Open positron96 opened 2 years ago

positron96 commented 2 years ago

Bug type: Language Service

Describe the bug

After I start VS Code and it loads previous PlatformIO project, it spawns cpptools-srv process. After 2-5 seconds, it allocates around 8 Gb of RAM and stays this way. If VS Code starts another cpptool-srv process, it jumps to these levels of allocation as well. Fortunately, it's virtual memory that is not mapped to actual RAM (actual RAM usage remains at sane levels), but it's still discomforting. A screenshot below shows both RAM values.

The workspace consists of one project. The project itself is a PlatformIO project that is an embedded Arduino firmware. If system sources are counted, total file count might be a hundred or so, but the project itself only has at most a dozen files. Any platformio project triggers this behavior, for ARM, AVR, ESP32 architectures and compiler toolchains.

On another machine (Win 10 x64) with the same project, cpptools-srv RAM allocation is only slightly larger than actual RAM usage (around 200-400 Mb, which seems reasonable and does not depend much on the number of files in project)

Expected behavior RAM commit levels should be similar to actual RAM usage (and it is on another machine).

Code sample and logs

Configurations in `c_cpp_properties.json` ``` // // !!! WARNING !!! AUTO-GENERATED FILE! // PLEASE DO NOT MODIFY IT AND USE "platformio.ini": // https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags // { "configurations": [ { "name": "PlatformIO", "includePath": [ "e:/Documents/PlatformIO/Projects/joysticktest/include", "e:/Documents/PlatformIO/Projects/joysticktest/src", "e:/Documents/PlatformIO/Projects/joysticktest/lib/ArduinoJoystickLibrary/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/cores/arduino", "C:/Users/positron/.platformio/packages/framework-arduino-avr/variants/micro", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/HID/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/SPI/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/Wire/src", "C:/Users/positron/.platformio/packages/tool-unity", "" ], "browse": { "limitSymbolsToIncludedHeaders": true, "path": [ "e:/Documents/PlatformIO/Projects/joysticktest/include", "e:/Documents/PlatformIO/Projects/joysticktest/src", "e:/Documents/PlatformIO/Projects/joysticktest/lib/ArduinoJoystickLibrary/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/cores/arduino", "C:/Users/positron/.platformio/packages/framework-arduino-avr/variants/micro", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/HID/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/SPI/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/Wire/src", "C:/Users/positron/.platformio/packages/tool-unity", "" ] }, "defines": [ "PLATFORMIO=50205", "ARDUINO_AVR_MICRO", "F_CPU=16000000L", "ARDUINO_ARCH_AVR", "ARDUINO=10808", "USB_VID=0x2341", "USB_PID=0x8037", "USB_PRODUCT=\"Arduino Micro\"", "USB_MANUFACTURER=\"Arduino\"", "__AVR_ATmega32U4__", "" ], "cStandard": "c11", "cppStandard": "c++11", "compilerPath": "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe", "compilerArgs": [ "-mmcu=atmega32u4", "" ] } ], "version": 4 } ```
Logs from running `C/C++: Log Diagnostics` from the VS Code command palette ``` -------- Diagnostics - 06.04.2022, 01:55:53 Version: 1.9.7 Current Configuration: { "name": "PlatformIO", "includePath": [ "e:/Documents/PlatformIO/Projects/joysticktest/include", "e:/Documents/PlatformIO/Projects/joysticktest/src", "e:/Documents/PlatformIO/Projects/joysticktest/lib/ArduinoJoystickLibrary/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/cores/arduino", "C:/Users/positron/.platformio/packages/framework-arduino-avr/variants/micro", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/HID/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/SPI/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/Wire/src", "C:/Users/positron/.platformio/packages/tool-unity" ], "browse": { "limitSymbolsToIncludedHeaders": true, "path": [ "e:/Documents/PlatformIO/Projects/joysticktest/include", "e:/Documents/PlatformIO/Projects/joysticktest/src", "e:/Documents/PlatformIO/Projects/joysticktest/lib/ArduinoJoystickLibrary/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/cores/arduino", "C:/Users/positron/.platformio/packages/framework-arduino-avr/variants/micro", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/HID/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/SPI/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", "C:/Users/positron/.platformio/packages/framework-arduino-avr/libraries/Wire/src", "C:/Users/positron/.platformio/packages/tool-unity" ] }, "defines": [ "PLATFORMIO=50205", "ARDUINO_AVR_MICRO", "F_CPU=16000000L", "ARDUINO_ARCH_AVR", "ARDUINO=10808", "USB_VID=0x2341", "USB_PID=0x8037", "USB_PRODUCT=\"Arduino Micro\"", "USB_MANUFACTURER=\"Arduino\"", "__AVR_ATmega32U4__", "" ], "cStandard": "c11", "cppStandard": "c++11", "compilerPath": "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe", "compilerArgs": [ "-mmcu=atmega32u4", "" ], "compilerPathIsExplicit": true, "cStandardIsExplicit": true, "cppStandardIsExplicit": true, "intelliSenseModeIsExplicit": false, "mergeConfigurations": false } Translation Unit Mappings: [ C:\Users\positron\.platformio\packages\framework-arduino-avr\cores\arduino\USBCore.cpp ]: C:\Users\positron\.platformio\packages\framework-arduino-avr\cores\arduino\USBCore.cpp C:\Users\positron\.platformio\packages\framework-arduino-avr\cores\arduino\USBCore.h * Translation Unit Configurations: [ C:\Users\positron\.platformio\packages\framework-arduino-avr\cores\arduino\USBCore.cpp ]: Process ID: 1452 Memory Usage: 25 MB Compiler Path: C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe Includes: E:\DOCUMENTS\PLATFORMIO\PROJECTS\JOYSTICKTEST\INCLUDE E:\DOCUMENTS\PLATFORMIO\PROJECTS\JOYSTICKTEST\SRC E:\DOCUMENTS\PLATFORMIO\PROJECTS\JOYSTICKTEST\LIB\ARDUINOJOYSTICKLIBRARY\SRC C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\CORES\ARDUINO C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\VARIANTS\MICRO C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\EEPROM\SRC C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\HID\SRC C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\SPI\SRC C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\SOFTWARESERIAL\SRC C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\WIRE\SRC C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\TOOL-UNITY C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\TOOLCHAIN-ATMELAVR\LIB\GCC\AVR\7.3.0\INCLUDE C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\TOOLCHAIN-ATMELAVR\LIB\GCC\AVR\7.3.0\INCLUDE-FIXED C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\TOOLCHAIN-ATMELAVR\AVR\INCLUDE Defines: PLATFORMIO=50205 ARDUINO_AVR_MICRO F_CPU=16000000L ARDUINO_ARCH_AVR ARDUINO=10808 USB_VID=0x2341 USB_PID=0x8037 USB_PRODUCT="Arduino Micro" USB_MANUFACTURER="Arduino" __AVR_ATmega32U4__ Standard Version: c++11 IntelliSense Mode: windows-gcc-x64 Other Flags: --g++ --gnu_version=70300 Total Memory Usage: 25 MB ------- Workspace parsing diagnostics ------- Number of files discovered (not excluded): 448 Number of files parsed: 396 ```
Logs from [the language server logging](https://code.visualstudio.com/docs/cpp/enable-logging-cpp#_enable-logging-for-the-language-server) ``` loggingLevel: Debug cpptools/didChangeCppProperties Code browsing service initialized Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe' Querying compiler for default C++ language standard using command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -x c++ -E -dM nul Detected language standard version: gnu++14 Querying compiler for default C language standard using command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -x c -E -dM nul Detected language standard version: gnu11 Querying compiler's default target using command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -dumpmachine Compiler returned default target value: avr Unhandled default compiler target value detected: avr Compiler query command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -mmcu=atmega32u4 -std=c++11 -Wp,-v -E -dM -x c++ -m64 nul Compiler does not support 64-bit. Falling back to 32-bit intelliSenseMode. Compiler query command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -mmcu=atmega32u4 -std=c++11 -Wp,-v -E -dM -x c++ -m32 nul Failed to query compiler. Falling back to no bitness. Compiler query command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -mmcu=atmega32u4 -std=c++11 -Wp,-v -E -dM -x c++ nul Attempting to get defaults from C compiler in "compilerPath" property: 'C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe' Compiler query command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -mmcu=atmega32u4 -std=c11 -Wp,-v -E -dM -x c -m64 nul Compiler does not support 64-bit. Falling back to 32-bit intelliSenseMode. Compiler query command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -mmcu=atmega32u4 -std=c11 -Wp,-v -E -dM -x c -m32 nul Failed to query compiler. Falling back to no bitness. Compiler query command line: "C:/Users/positron/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe" -mmcu=atmega32u4 -std=c11 -Wp,-v -E -dM -x c nul Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/TOOLCHAIN-ATMELAVR/AVR/INCLUDE/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/TOOLCHAIN-ATMELAVR/LIB/GCC/AVR/7.3.0/INCLUDE/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/TOOLCHAIN-ATMELAVR/LIB/GCC/AVR/7.3.0/INCLUDE-FIXED/ will be indexed Folder: E:/DOCUMENTS/PLATFORMIO/PROJECTS/JOYSTICKTEST/INCLUDE/ will be indexed Folder: E:/DOCUMENTS/PLATFORMIO/PROJECTS/JOYSTICKTEST/SRC/ will be indexed Folder: E:/DOCUMENTS/PLATFORMIO/PROJECTS/JOYSTICKTEST/LIB/ARDUINOJOYSTICKLIBRARY/SRC/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/CORES/ARDUINO/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/VARIANTS/MICRO/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/EEPROM/SRC/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/HID/SRC/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/SPI/SRC/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/SOFTWARESERIAL/SRC/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/WIRE/SRC/ will be indexed Folder: C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/TOOL-UNITY/ will be indexed cpptools/didChangeSettings IntelliSense Engine = Default. Enhanced Colorization is enabled. Error squiggles are enabled if all header dependencies are resolved. Autocomplete is enabled. Discovering files... Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/TOOLCHAIN-ATMELAVR/AVR/INCLUDE/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/TOOLCHAIN-ATMELAVR/LIB/GCC/AVR/7.3.0/INCLUDE/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/TOOLCHAIN-ATMELAVR/LIB/GCC/AVR/7.3.0/INCLUDE-FIXED/ Processing folder (recursive): E:/DOCUMENTS/PLATFORMIO/PROJECTS/JOYSTICKTEST/INCLUDE/ Processing folder (recursive): E:/DOCUMENTS/PLATFORMIO/PROJECTS/JOYSTICKTEST/SRC/ Processing folder (recursive): E:/DOCUMENTS/PLATFORMIO/PROJECTS/JOYSTICKTEST/LIB/ARDUINOJOYSTICKLIBRARY/SRC/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/CORES/ARDUINO/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/VARIANTS/MICRO/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/EEPROM/SRC/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/HID/SRC/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/SPI/SRC/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/SOFTWARESERIAL/SRC/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/FRAMEWORK-ARDUINO-AVR/LIBRARIES/WIRE/SRC/ Processing folder (recursive): C:/USERS/POSITRON/.PLATFORMIO/PACKAGES/TOOL-UNITY/ Discovering files: 448 file(s) processed 0 file(s) removed from database Done discovering files. Populating include completion cache. Parsing remaining files... Parsing: 0 files(s) processed Done parsing remaining files. cpptools/didChangeCppProperties cpptools/getCodeActions: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp (id: 2) textDocument/didOpen: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp cpptools/textEditorSelectionChange cpptools/getDocumentSymbols: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp (id: 3) cpptools/textEditorSelectionChange cpptools/getSemanticTokens: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp (id: 4) cpptools/activeDocumentChange: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp cpptools/getDocumentSymbols sending compilation args for E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp include: E:\DOCUMENTS\PLATFORMIO\PROJECTS\JOYSTICKTEST\INCLUDE include: E:\DOCUMENTS\PLATFORMIO\PROJECTS\JOYSTICKTEST\SRC include: E:\DOCUMENTS\PLATFORMIO\PROJECTS\JOYSTICKTEST\LIB\ARDUINOJOYSTICKLIBRARY\SRC include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\CORES\ARDUINO include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\VARIANTS\MICRO include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\EEPROM\SRC include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\HID\SRC include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\SPI\SRC include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\SOFTWARESERIAL\SRC include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\FRAMEWORK-ARDUINO-AVR\LIBRARIES\WIRE\SRC include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\TOOL-UNITY include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\TOOLCHAIN-ATMELAVR\LIB\GCC\AVR\7.3.0\INCLUDE include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\TOOLCHAIN-ATMELAVR\LIB\GCC\AVR\7.3.0\INCLUDE-FIXED include: C:\USERS\POSITRON\.PLATFORMIO\PACKAGES\TOOLCHAIN-ATMELAVR\AVR\INCLUDE define: __DBL_MIN_EXP__=(-125) define: __HQ_FBIT__=15 define: __UINT_LEAST16_MAX__=0xffffU define: __ATOMIC_ACQUIRE=2 define: __SFRACT_IBIT__=0 define: __FLT_MIN__=1.17549435e-38F define: __GCC_IEC_559_COMPLEX=0 define: __BUILTIN_AVR_SLEEP=1 define: __BUILTIN_AVR_COUNTLSULLK=1 define: __BUILTIN_AVR_COUNTLSULLR=1 define: __UFRACT_MAX__=0XFFFFP-16UR define: __UINT_LEAST8_TYPE__=unsigned char define: __DQ_FBIT__=63 define: __INTMAX_C(c)=c ## LL define: __ULFRACT_FBIT__=32 define: __SACCUM_EPSILON__=0x1P-7HK define: __CHAR_BIT__=8 define: __USQ_IBIT__=0 define: __UINT8_MAX__=0xff define: __ACCUM_FBIT__=15 define: __WINT_MAX__=0x7fff define: __FLT32_MIN_EXP__=(-125) define: __USFRACT_FBIT__=8 define: __ORDER_LITTLE_ENDIAN__=1234 define: __SIZE_MAX__=0xffffU define: __WCHAR_MAX__=0x7fff define: __LACCUM_IBIT__=32 define: __DBL_DENORM_MIN__=double(1.40129846e-45L) define: __GCC_ATOMIC_CHAR_LOCK_FREE=1 define: __GCC_IEC_559=0 define: __FLT_EVAL_METHOD__=0 define: __BUILTIN_AVR_LLKBITS=1 define: __LLACCUM_MAX__=0X7FFFFFFFFFFFFFFFP-47LLK define: __GCC_ATOMIC_CHAR32_T_LOCK_FREE=1 define: __BUILTIN_AVR_HKBITS=1 define: __BUILTIN_AVR_BITSLLK=1 define: __FRACT_FBIT__=15 define: __BUILTIN_AVR_BITSLLR=1 define: __UINT_FAST64_MAX__=0xffffffffffffffffULL define: __SIG_ATOMIC_TYPE__=char define: __BUILTIN_AVR_UHKBITS=1 define: __UACCUM_FBIT__=16 define: __DBL_MIN_10_EXP__=(-37) define: __FINITE_MATH_ONLY__=0 define: __LFRACT_IBIT__=0 define: __GNUC_PATCHLEVEL__=0 define: __FLT32_HAS_DENORM__=1 define: __AVR_MEGA__=1 define: __LFRACT_MAX__=0X7FFFFFFFP-31LR define: __UINT_FAST8_MAX__=0xff define: __DEC64_MAX_EXP__=385 define: __INT8_C(c)=c define: __INT_LEAST8_WIDTH__=8 define: __UINT_LEAST64_MAX__=0xffffffffffffffffULL define: __SA_FBIT__=15 define: __SHRT_MAX__=0x7fff define: __LDBL_MAX__=3.40282347e+38L define: __FRACT_MAX__=0X7FFFP-15R define: __UFRACT_FBIT__=16 define: __UFRACT_MIN__=0.0UR define: __UINT_LEAST8_MAX__=0xff define: __GCC_ATOMIC_BOOL_LOCK_FREE=1 define: __UINTMAX_TYPE__=long long unsigned int define: __LLFRACT_EPSILON__=0x1P-63LLR define: __BUILTIN_AVR_DELAY_CYCLES=1 define: __DEC32_EPSILON__=1E-6DF define: __FLT_EVAL_METHOD_TS_18661_3__=0 define: __UINT32_MAX__=0xffffffffUL define: __GXX_EXPERIMENTAL_CXX0X__=1 define: __ULFRACT_MAX__=0XFFFFFFFFP-32ULR define: __TA_IBIT__=16 define: __LDBL_MAX_EXP__=128 define: __WINT_MIN__=(-__WINT_MAX__ - 1) define: __INT_LEAST16_WIDTH__=16 define: __ULLFRACT_MIN__=0.0ULLR define: __SCHAR_MAX__=0x7f define: __WCHAR_MIN__=(-__WCHAR_MAX__ - 1) define: __INT64_C(c)=c ## LL define: __DBL_DIG__=6 define: __GCC_ATOMIC_POINTER_LOCK_FREE=1 define: __AVR_HAVE_SPH__=1 define: __LLACCUM_MIN__=(-0X1P15LLK-0X1P15LLK) define: __BUILTIN_AVR_KBITS=1 define: __BUILTIN_AVR_ABSK=1 define: __BUILTIN_AVR_ABSR=1 define: __SIZEOF_INT__=2 define: __SIZEOF_POINTER__=2 define: __GCC_ATOMIC_CHAR16_T_LOCK_FREE=1 define: __USACCUM_IBIT__=8 define: __USER_LABEL_PREFIX__= define: __STDC_HOSTED__=1 define: __LDBL_HAS_INFINITY__=1 define: __LFRACT_MIN__=(-0.5LR-0.5LR) define: __HA_IBIT__=8 define: __FLT32_DIG__=6 define: __TQ_IBIT__=0 define: __FLT_EPSILON__=1.19209290e-7F define: __GXX_WEAK__=1 define: __SHRT_WIDTH__=16 define: __USFRACT_IBIT__=0 define: __LDBL_MIN__=1.17549435e-38L define: __FRACT_MIN__=(-0.5R-0.5R) define: __AVR_SFR_OFFSET__=0x20 define: __DEC32_MAX__=9.999999E96DF define: __DA_IBIT__=32 define: __INT32_MAX__=0x7fffffffL define: __UQQ_FBIT__=8 define: __INT_WIDTH__=16 define: __SIZEOF_LONG__=4 define: __UACCUM_MAX__=0XFFFFFFFFP-16UK define: __UINT16_C(c)=c ## U define: __PTRDIFF_WIDTH__=16 define: __DECIMAL_DIG__=9 define: __LFRACT_EPSILON__=0x1P-31LR define: __AVR_2_BYTE_PC__=1 define: __ULFRACT_MIN__=0.0ULR define: __INTMAX_WIDTH__=64 define: __BUILTIN_AVR_ULLRBITS=1 define: __LDBL_HAS_QUIET_NAN__=1 define: __ULACCUM_IBIT__=32 define: __UACCUM_EPSILON__=0x1P-16UK define: __BUILTIN_AVR_SEI=1 define: __GNUC__=7 define: __ULLACCUM_MAX__=0XFFFFFFFFFFFFFFFFP-48ULLK define: __HQ_IBIT__=0 define: __BUILTIN_AVR_SWAP=1 define: __FLT_HAS_DENORM__=1 define: __SIZEOF_LONG_DOUBLE__=4 define: __BIGGEST_ALIGNMENT__=1 define: __STDC_UTF_16__=1 define: __UINT24_MAX__=16777215UL define: __BUILTIN_AVR_NOP=1 define: __GNUC_STDC_INLINE__=1 define: __DQ_IBIT__=0 define: __FLT32_HAS_INFINITY__=1 define: __DBL_MAX__=double(3.40282347e+38L) define: __ULFRACT_IBIT__=0 define: __INT_FAST32_MAX__=0x7fffffffL define: __DBL_HAS_INFINITY__=1 define: __INT64_MAX__=0x7fffffffffffffffLL define: __ACCUM_IBIT__=16 define: __DEC32_MIN_EXP__=(-94) define: __BUILTIN_AVR_UKBITS=1 define: __INTPTR_WIDTH__=16 define: __BUILTIN_AVR_FMULSU=1 define: __LACCUM_MAX__=0X7FFFFFFFFFFFFFFFP-31LK define: __INT_FAST16_TYPE__=int define: __STRICT_ANSI__=1 define: __LDBL_HAS_DENORM__=1 define: __BUILTIN_AVR_BITSK=1 define: __BUILTIN_AVR_BITSR=1 define: __cplusplus=201103L define: __DEC128_MAX__=9.999999999999999999999999999999999E6144DL define: __INT_LEAST32_MAX__=0x7fffffffL define: __USING_SJLJ_EXCEPTIONS__=1 define: __DEC32_MIN__=1E-95DF define: __ACCUM_MAX__=0X7FFFFFFFP-15K define: __DEPRECATED=1 define: __DBL_MAX_EXP__=128 define: __USACCUM_EPSILON__=0x1P-8UHK define: __WCHAR_WIDTH__=16 define: __FLT32_MAX__=3.40282347e+38F32 define: __DEC128_EPSILON__=1E-33DL define: __SFRACT_MAX__=0X7FP-7HR define: __FRACT_IBIT__=0 define: __PTRDIFF_MAX__=0x7fff define: __UACCUM_MIN__=0.0UK define: __AVR_ENHANCED__=1 define: __UACCUM_IBIT__=16 define: __BUILTIN_AVR_NOPS=1 define: __BUILTIN_AVR_WDR=1 define: __FLT32_HAS_QUIET_NAN__=1 define: __GNUG__=7 define: __LONG_LONG_MAX__=0x7fffffffffffffffLL define: __SIZEOF_SIZE_T__=2 define: __ULACCUM_MAX__=0XFFFFFFFFFFFFFFFFP-32ULK define: __SIZEOF_WINT_T__=2 define: __LONG_LONG_WIDTH__=64 define: __FLT32_MAX_EXP__=128 define: __SA_IBIT__=16 define: __ULLACCUM_MIN__=0.0ULLK define: __BUILTIN_AVR_ROUNDUHK=1 define: __BUILTIN_AVR_ROUNDUHR=1 define: __GXX_ABI_VERSION=1011 define: __INT24_MAX__=8388607L define: __UTA_FBIT__=48 define: __FLT_MIN_EXP__=(-125) define: __USFRACT_MAX__=0XFFP-8UHR define: __UFRACT_IBIT__=0 define: __BUILTIN_AVR_ROUNDFX=1 define: __BUILTIN_AVR_ROUNDULK=1 define: __BUILTIN_AVR_ROUNDULR=1 define: __BUILTIN_AVR_COUNTLSLLK=1 define: __BUILTIN_AVR_COUNTLSLLR=1 define: __BUILTIN_AVR_ROUNDHK=1 define: __INT_FAST64_TYPE__=long long int define: __BUILTIN_AVR_ROUNDHR=1 define: __DBL_MIN__=double(1.17549435e-38L) define: __BUILTIN_AVR_COUNTLSK=1 define: __BUILTIN_AVR_ROUNDLK=1 define: __BUILTIN_AVR_COUNTLSR=1 define: __BUILTIN_AVR_ROUNDLR=1 define: __LACCUM_MIN__=(-0X1P31LK-0X1P31LK) define: __ULLACCUM_FBIT__=48 define: __BUILTIN_AVR_LKBITS=1 define: __ULLFRACT_EPSILON__=0x1P-64ULLR define: __DEC128_MIN__=1E-6143DL define: __REGISTER_PREFIX__= define: __UINT16_MAX__=0xffffU define: __DBL_HAS_DENORM__=1 define: __BUILTIN_AVR_ULKBITS=1 define: __ACCUM_MIN__=(-0X1P15K-0X1P15K) define: __AVR_ARCH__=5 define: __SQ_IBIT__=0 define: __FLT32_MIN__=1.17549435e-38F32 define: __UINT8_TYPE__=unsigned char define: __BUILTIN_AVR_ROUNDUK=1 define: __BUILTIN_AVR_ROUNDUR=1 define: __UHA_FBIT__=8 define: __NO_INLINE__=1 define: __SFRACT_MIN__=(-0.5HR-0.5HR) define: __UTQ_FBIT__=128 define: __FLT_MANT_DIG__=24 define: __LDBL_DECIMAL_DIG__=9 define: __VERSION__="7.3.0" define: __UINT64_C(c)=c ## ULL define: __ULLFRACT_FBIT__=64 define: __FRACT_EPSILON__=0x1P-15R define: __ULACCUM_MIN__=0.0ULK define: __UDA_FBIT__=32 define: __LLACCUM_EPSILON__=0x1P-47LLK define: __GCC_ATOMIC_INT_LOCK_FREE=1 define: __FLT32_MANT_DIG__=24 define: __BUILTIN_AVR_BITSUHK=1 define: __BUILTIN_AVR_BITSUHR=1 define: __FLOAT_WORD_ORDER__=__ORDER_LITTLE_ENDIAN__ define: __USFRACT_MIN__=0.0UHR define: __BUILTIN_AVR_BITSULK=1 define: __ULLACCUM_IBIT__=16 define: __BUILTIN_AVR_BITSULR=1 define: __UQQ_IBIT__=0 define: __BUILTIN_AVR_LLRBITS=1 define: __SCHAR_WIDTH__=8 define: __BUILTIN_AVR_BITSULLK=1 define: __BUILTIN_AVR_BITSULLR=1 define: __INT32_C(c)=c ## L define: __DEC64_EPSILON__=1E-15DD define: __ORDER_PDP_ENDIAN__=3412 define: __DEC128_MIN_EXP__=(-6142) define: __UHQ_FBIT__=16 define: __LLACCUM_FBIT__=47 define: __FLT32_MAX_10_EXP__=38 define: __BUILTIN_AVR_ROUNDULLK=1 define: __BUILTIN_AVR_ROUNDULLR=1 define: __INT_FAST32_TYPE__=long int define: __BUILTIN_AVR_HRBITS=1 define: __UINT_LEAST16_TYPE__=unsigned int define: __BUILTIN_AVR_UHRBITS=1 define: __INT16_MAX__=0x7fff define: __SIZE_TYPE__=unsigned int define: __UINT64_MAX__=0xffffffffffffffffULL define: __UDQ_FBIT__=64 define: __INT8_TYPE__=signed char define: __AVR_ATmega32U4__=1 define: __ELF__=1 define: __ULFRACT_EPSILON__=0x1P-32ULR define: __LLFRACT_FBIT__=63 define: __FLT_RADIX__=2 define: __INT_LEAST16_TYPE__=int define: __BUILTIN_AVR_ABSFX=1 define: __LDBL_EPSILON__=1.19209290e-7L define: __UINTMAX_C(c)=c ## ULL define: __INT24_MIN__=(-__INT24_MAX__-1) define: __SACCUM_MAX__=0X7FFFP-7HK define: __BUILTIN_AVR_ABSHR=1 define: __SIG_ATOMIC_MAX__=0x7f define: __GCC_ATOMIC_WCHAR_T_LOCK_FREE=1 define: __SIZEOF_PTRDIFF_T__=2 define: __AVR=1 define: __BUILTIN_AVR_ABSLK=1 define: __BUILTIN_AVR_ABSLR=1 define: __LACCUM_EPSILON__=0x1P-31LK define: __DEC32_SUBNORMAL_MIN__=0.000001E-95DF define: __INT_FAST16_MAX__=0x7fff define: __UINT_FAST32_MAX__=0xffffffffUL define: __UINT_LEAST64_TYPE__=long long unsigned int define: __USACCUM_MAX__=0XFFFFP-8UHK define: __SFRACT_EPSILON__=0x1P-7HR define: __FLT_HAS_QUIET_NAN__=1 define: __FLT_MAX_10_EXP__=38 define: __LONG_MAX__=0x7fffffffL define: __DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL define: __FLT_HAS_INFINITY__=1 define: __USA_FBIT__=16 define: __UINT_FAST16_TYPE__=unsigned int define: __DEC64_MAX__=9.999999999999999E384DD define: __INT_FAST32_WIDTH__=32 define: __BUILTIN_AVR_RBITS=1 define: __CHAR16_TYPE__=unsigned int define: __PRAGMA_REDEFINE_EXTNAME=1 define: __AVR_HAVE_LPMX__=1 define: __SIZE_WIDTH__=16 define: __INT_LEAST16_MAX__=0x7fff define: __DEC64_MANT_DIG__=16 define: __UINT_LEAST32_MAX__=0xffffffffUL define: __SACCUM_FBIT__=7 define: __FLT32_DENORM_MIN__=1.40129846e-45F32 define: __GCC_ATOMIC_LONG_LOCK_FREE=1 define: __SIG_ATOMIC_WIDTH__=8 define: __INT_LEAST64_TYPE__=long long int define: __INT16_TYPE__=int define: __INT_LEAST8_TYPE__=signed char define: __SQ_FBIT__=31 define: __DEC32_MAX_EXP__=97 define: __INT_FAST8_MAX__=0x7f define: __INTPTR_MAX__=0x7fff define: __QQ_FBIT__=7 define: __UTA_IBIT__=16 define: __FLT32_MIN_10_EXP__=(-37) define: __LDBL_MANT_DIG__=24 define: __SFRACT_FBIT__=7 define: __SACCUM_MIN__=(-0X1P7HK-0X1P7HK) define: __DBL_HAS_QUIET_NAN__=1 define: __SIG_ATOMIC_MIN__=(-__SIG_ATOMIC_MAX__ - 1) define: __BUILTIN_AVR_FMULS=1 define: __INTPTR_TYPE__=int define: __UINT16_TYPE__=unsigned int define: __WCHAR_TYPE__=int define: __SIZEOF_FLOAT__=4 define: __AVR__=1 define: __BUILTIN_AVR_INSERT_BITS=1 define: __AVR_HAVE_JMP_CALL__=1 define: __USQ_FBIT__=32 define: __UINTPTR_MAX__=0xffffU define: __INT_FAST64_WIDTH__=64 define: __DEC64_MIN_EXP__=(-382) define: __FLT32_DECIMAL_DIG__=9 define: __INT_FAST64_MAX__=0x7fffffffffffffffLL define: __GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 define: __FLT_DIG__=6 define: __UINT_FAST64_TYPE__=long long unsigned int define: __BUILTIN_AVR_BITSHK=1 define: __BUILTIN_AVR_BITSHR=1 define: __INT_MAX__=0x7fff define: __LACCUM_FBIT__=31 define: __USACCUM_MIN__=0.0UHK define: __UHA_IBIT__=8 define: __INT64_TYPE__=long long int define: __BUILTIN_AVR_BITSLK=1 define: __BUILTIN_AVR_BITSLR=1 define: __FLT_MAX_EXP__=128 define: __AVR_HAVE_MUL__=1 define: __UTQ_IBIT__=0 define: __DBL_MANT_DIG__=24 define: __BUILTIN_AVR_ULLKBITS=1 define: __INT_LEAST64_MAX__=0x7fffffffffffffffLL define: __AVR_HAVE_MOVW__=1 define: __DEC64_MIN__=1E-383DD define: __WINT_TYPE__=int define: __UINT_LEAST32_TYPE__=long unsigned int define: __SIZEOF_SHORT__=2 define: __ULLFRACT_IBIT__=0 define: __LDBL_MIN_EXP__=(-125) define: __UDA_IBIT__=32 define: __WINT_WIDTH__=16 define: __INT_LEAST8_MAX__=0x7f define: __LFRACT_FBIT__=31 define: __LDBL_MAX_10_EXP__=38 define: __ATOMIC_RELAXED=0 define: __DBL_EPSILON__=double(1.19209290e-7L) define: __BUILTIN_AVR_BITSUK=1 define: __BUILTIN_AVR_BITSUR=1 define: __UINT8_C(c)=c define: __INT_LEAST32_TYPE__=long int define: __BUILTIN_AVR_URBITS=1 define: __SIZEOF_WCHAR_T__=2 define: __LLFRACT_MAX__=0X7FFFFFFFFFFFFFFFP-63LLR define: __TQ_FBIT__=127 define: __INT_FAST8_TYPE__=signed char define: __ULLACCUM_EPSILON__=0x1P-48ULLK define: __BUILTIN_AVR_ROUNDK=1 define: __BUILTIN_AVR_ROUNDR=1 define: __UHQ_IBIT__=0 define: __LLACCUM_IBIT__=16 define: __FLT32_EPSILON__=1.19209290e-7F32 define: __AVR_DEVICE_NAME__=atmega32u4 define: __DBL_DECIMAL_DIG__=9 define: __STDC_UTF_32__=1 define: __INT_FAST8_WIDTH__=8 define: __DEC_EVAL_METHOD__=2 define: __TA_FBIT__=47 define: __UDQ_IBIT__=0 define: __ORDER_BIG_ENDIAN__=4321 define: __WITH_AVRLIBC__=1 define: __UINT64_TYPE__=long long unsigned int define: __ACCUM_EPSILON__=0x1P-15K define: __UINT32_C(c)=c ## UL define: __BUILTIN_AVR_COUNTLSUHK=1 define: __INTMAX_MAX__=0x7fffffffffffffffLL define: __BUILTIN_AVR_COUNTLSUHR=1 define: __BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__ define: __FLT_DENORM_MIN__=1.40129846e-45F define: __LLFRACT_IBIT__=0 define: __INT8_MAX__=0x7f define: __LONG_WIDTH__=32 define: __UINT_FAST32_TYPE__=long unsigned int define: __CHAR32_TYPE__=long unsigned int define: __BUILTIN_AVR_COUNTLSULK=1 define: __BUILTIN_AVR_COUNTLSULR=1 define: __FLT_MAX__=3.40282347e+38F define: __USACCUM_FBIT__=8 define: __BUILTIN_AVR_COUNTLSFX=1 define: __INT32_TYPE__=long int define: __SIZEOF_DOUBLE__=4 define: __FLT_MIN_10_EXP__=(-37) define: __UFRACT_EPSILON__=0x1P-16UR define: __INT_LEAST32_WIDTH__=32 define: __BUILTIN_AVR_COUNTLSHK=1 define: __BUILTIN_AVR_COUNTLSHR=1 define: __INTMAX_TYPE__=long long int define: __BUILTIN_AVR_ABSLLK=1 define: __BUILTIN_AVR_ABSLLR=1 define: __DEC128_MAX_EXP__=6145 define: __AVR_HAVE_16BIT_SP__=1 define: __ATOMIC_CONSUME=1 define: __GNUC_MINOR__=3 define: __INT_FAST16_WIDTH__=16 define: __UINTMAX_MAX__=0xffffffffffffffffULL define: __DEC32_MANT_DIG__=7 define: __HA_FBIT__=7 define: __BUILTIN_AVR_COUNTLSLK=1 define: __BUILTIN_AVR_COUNTLSLR=1 define: __BUILTIN_AVR_CLI=1 define: __DBL_MAX_10_EXP__=38 define: __LDBL_DENORM_MIN__=1.40129846e-45L define: __INT16_C(c)=c define: __STDC__=1 define: __PTRDIFF_TYPE__=int define: __LLFRACT_MIN__=(-0.5LLR-0.5LLR) define: __BUILTIN_AVR_LRBITS=1 define: __ATOMIC_SEQ_CST=5 define: __DA_FBIT__=31 define: __UINT32_TYPE__=long unsigned int define: __BUILTIN_AVR_ROUNDLLK=1 define: __UINTPTR_TYPE__=unsigned int define: __BUILTIN_AVR_ROUNDLLR=1 define: __USA_IBIT__=16 define: __BUILTIN_AVR_ULRBITS=1 define: __DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD define: __DEC128_MANT_DIG__=34 define: __LDBL_MIN_10_EXP__=(-37) define: __BUILTIN_AVR_COUNTLSUK=1 define: __BUILTIN_AVR_COUNTLSUR=1 define: __SIZEOF_LONG_LONG__=8 define: __ULACCUM_EPSILON__=0x1P-32ULK define: __SACCUM_IBIT__=8 define: __GCC_ATOMIC_LLONG_LOCK_FREE=1 define: __LDBL_DIG__=6 define: __FLT_DECIMAL_DIG__=9 define: __UINT_FAST16_MAX__=0xffffU define: __GCC_ATOMIC_SHORT_LOCK_FREE=1 define: __BUILTIN_AVR_ABSHK=1 define: __BUILTIN_AVR_FLASH_SEGMENT=1 define: __INT_LEAST64_WIDTH__=64 define: __ULLFRACT_MAX__=0XFFFFFFFFFFFFFFFFP-64ULLR define: __UINT_FAST8_TYPE__=unsigned char define: __USFRACT_EPSILON__=0x1P-8UHR define: __ULACCUM_FBIT__=32 define: __QQ_IBIT__=0 define: __ATOMIC_ACQ_REL=4 define: __ATOMIC_RELEASE=3 define: __BUILTIN_AVR_FMUL=1 define: PLATFORMIO=50205 define: ARDUINO_AVR_MICRO define: F_CPU=16000000L define: ARDUINO_ARCH_AVR define: ARDUINO=10808 define: USB_VID=0x2341 define: USB_PID=0x8037 define: USB_PRODUCT="Arduino Micro" define: USB_MANUFACTURER="Arduino" define: __AVR_ATmega32U4__ other: --g++ other: --gnu_version=70300 stdver: c++11 intelliSenseMode: windows-gcc-x64 Checking for syntax errors: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp Queueing IntelliSense update for files in translation unit of: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp cpptools/getCodeActions: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp (id: 5) cpptools/getFoldingRanges: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp (id: 6) cpptools/finishUpdateSquiggles Error squiggle count: 0 Update IntelliSense time (sec): 0.945 cpptools/getFoldingRanges: E:\Documents\PlatformIO\Projects\joysticktest\src\main.cpp (id: 7) ```

Screenshots

Here is a screenshot of process explorer:

Additional context

sean-mcmanus commented 2 years ago

This might just be an issue with how Windows 7 reports the memory usage. What is the "Commit Size" reported as? I'm guessing it could be due to memory mapping of a large address space for ipch files -- if you set C_Cpp.intelliSenseCacheSize to 0 does it stop reproing?

positron96 commented 2 years ago

This might just be an issue with how Windows 7 reports the memory usage. What is the "Commit Size" reported as?

Sorry, how do I check this?

I'm guessing it could be due to memory mapping of a large address space for ipch files -- if you set C_Cpp.intelliSenseCacheSize to 0 does it stop reproing?

Yes, if that is set to 0, both committed size and working set size are 21-25 Mb. What do I loose if I keep cache size at 0?

sean-mcmanus commented 2 years ago

I think in Task Manager you can right-click the columns of the Details tab and choose Select Columns to add the Commit Size column.

Setting the C_Cpp.intelliSenseCacheSize to 0 just stops creating generating the .ipch cache files for headers -- it's usually supposed to make IntelliSense updating faster, but there are cases where it could be slower and you may not notice any performance difference either way. The ipch cache files get memory mapped, i.e. a big chunk of virtural memory address space is allocated, but the memory should not be used/committed until the particular file/memory location is accessed, so it shouldn't impact the performance on your system or significantly reduce the memory available, etc.

positron96 commented 2 years ago

"Commit size" in Task Manager looks like it's the same column called "Private bytes" in Process Explorer on the first screenshot. So it shows the same 8Gb for cpptools-srv when intelliSenseCacheSize is not 0.

sean-mcmanus commented 2 years ago

That is not expected. I'll see if anyone on our team is able to repro that. I'm not sure if it's a bug with the Task Manager or some other difference in Win7.

positron96 commented 2 years ago

Thanks! Let me know if any further information needed, I'll try to gather it on my machine.

bobbrow commented 2 years ago

I opened a few large source files on Windows 7 (VM) and the private bytes was in the 300 MB range. This doesn't appear to be a bug in Task Manager as I got the same result there.

Is there a project we can clone to aid in our investigation? There's something special about yours. Does it repro with any PlatformIO project?

sean-mcmanus commented 2 years ago

Since we haven't reproed the issue yet on Win7, it could be a bug with their specific OS installation or Task Manager.

positron96 commented 2 years ago

Hi. I've been able to successfully reproduce this on another Win7x64 box (inside VirtualBox) with fresh install of VS Code and PlatformIO. I've used this code: https://github.com/positron96/cnc3018-offline-controller but on my original machine the issue reproduces with any PlatformIO project. Also, both Windows Task Manager and Sysinternals Process Explorer are affected, so this is probably not a Task Manager bug (see on the screenshot).

VirtualBox_win7box-full_12_04_2022_11_50_49

kutukvpavel commented 2 years ago

I ran into this exact issue today too, after installing Espressif IDF extension and getting hello world project up and running. I am running swapless with 12GB of RAM, so upon allocation of an 8GB commit (as reported by resource monitor) I can actually get an out-of-(virtual)-memory system warning, followed shortly by VSCode window crash. So this is probably not a task manager issue.

VSCode v1.65.2, c/cpp v1.9.8, Win7x64.

The thing is, the issue is intermittent for me. So no debug logs yet.

I spent several hours playing around with building etc after I configured intellisense, and everything was running fine. However, after I happened to restart VSCode several times in a row in a rather quick manner (coincedentally, within a minute after a reboot), I was hit with the first out of memory warning. While I was investigating, VSCode eventually crashed. So I started it again, and again to no avail: allocation af an 8GB commit on startup persisted.

Then I waited for a couple minutes, launched VSCode again, and the 8GB commit was no more. I tried to reproduce the issue by rapidly restarting VSCode several times again, but no luck yet.

P.S. I've used VSCode with STM32 HAL libraries that constitute a codebase of roughly the same size as Espressif IDF. I've used PlatformIO too, occasionally. Never seen anything like this before. Maybe the issue is not related to the codebase size at all.

AndreKR commented 2 years ago

I also experience this issue and I concur that it is probably not dependent on the size of the codebase.

I used ProcessMonitor to look at all the files that cpptools-srv.exe accessed and it was only about 150 files in total, about 60 of those were code files (mostly .h), the rest were DLLs, config files, etc.
Total bytes read were about 600 kB.

Also, it takes only a second or two between process start and the allocation. Or more precisely during the startup of VS Code cpptools-srv.exe gets started and ended a couple of times and one of those processes survives and that one grabs 8 GB of memory about 2 seconds after it has started.

I can reproduce the issue pretty much every time I start VS Code with the C/C++ extension pack enabled, so if you want me to investigate something, let me know.

Edit:
Setting intelliSenseCacheSize to 0 seems to fix the issue.

@sean-mcmanus

a big chunk of virtural memory address space is allocated, but the memory should not be used/committed until the particular file/memory location is accessed, so it shouldn't impact the performance on your system or significantly reduce the memory available, etc.

Are you sure this applies to Windows? I'm not super strong on the subtleties of memory mapped files but I know for sure that for normal allocations overcommmit does not exist on Windows. On Linux (which has memory overcommit) it isn't a big deal to just allocate a lot of memory as long as you don't use it, but on Windows every allocation has to come out of physical or swap memory to be honored. As soon as that is used up by allocations, further allocations on the system will fail and many programs (Google Chrome is one example) will start crashing when they get failed allocations. It does not matter a bit whether or not the allocated memory was actually ever used.

sean-mcmanus commented 2 years ago

@AndreKR What OS are you on? Win7? Yeah, I'd recommend setting intelliSenseCacheSize to 0 for anyone who hits this.

I don't think anyone on our team has witnessed the issue in which cpptools-srv.exe with the IntelliSenseCache on Windows creates a 2-8 GB commit of memory on Windows. Normally, it might allocate 4 GB of virtual memory space, but only 300 MB or so would be committed in to physical or swap memory.

AndreKR commented 2 years ago

I can reproduce it even without restarting VS Code. The actual number of intelliSenseCacheSize does not seem to matter:

https://user-images.githubusercontent.com/1188538/171841348-99450c94-d141-478c-a310-06bb9fdd445d.mp4

it might allocate 4 GB of virtual memory space, but only 300 MB or so would be committed in to physical or swap memory

I don't understand the distinction. On Windows (Linux is different) you can't "allocate" 4 GB without actually taking up 4 GB of memory. The moment you allocate it, it will be reserved for you and is unavailable for other applications, which then get failed allocations and (usually) crash.

sean-mcmanus commented 2 years ago

@AndreKR See https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc -- it says "MEM_RESERVE: Reserves a range of the process's virtual address space without allocating any actual physical storage in memory or in the paging file on disk..". Under normal circumstances, we don't see 4-8 GB of committed memory, only reserved address space. It's possible there has been some modification to your OS/kernel32.dll to trigger a different behavior, apps such as appverif.exe could have similar but different effects. We don't know what is causing this yet.

sean-mcmanus commented 2 years ago

@AndreKR I just debugged it and I see us calling the VirtualAlloc with MEM_RESERVE with a large value, but small values when MEM_COMMIT is used. You may be able to use a system tool such as Process Monitor to see the VirtualAlloc calls made by the cpptools-srv process to see what flags/values are being used in your case. It seems as if there may be some "bug" in your OS that is causing MEM_RESERVE to be treated as MEM_COMMIT.

al20878 commented 2 years ago

I am seeing exactly the same insane 8G "private bytes" for cpptools-srv.exe (and it's only one .c file loaded in VSCode)...

al20878 commented 2 years ago

IntelliSense8GB

sean-mcmanus commented 2 years ago

@al20878 If you could get more info via Process Monitor (not process explorer) that could help, in particular logging related to the VirtualAlloc call with the large request. Our current guess is it's some OS bug with Win7.

sean-mcmanus commented 2 years ago

@al20878 The workaround should be to set C_Cpp.intelliSenseCacheSize to 0.

al20878 commented 2 years ago

The workaround should be to set C_Cpp.intelliSenseCacheSize to 0.

I've seen that above in the thread, but that does not look like a proper "workaround". It just hides the problem. Besides, I guess dropping the cache altogether is not a good thing on itself -- I suppose it's there for a reason.

sean-mcmanus commented 2 years ago

@al20878 The cache is not essential and in some cases may hurt performance anyway. The cache writes the compiled header code to a file and memory maps it, but that can cause additional disk read/writes, particularly if the disk is slower and/or if the header is changing a lot. You could compare the performance with the cache on/off to see if you see a performance difference. In most cases, the difference in performance probably wouldn't be noticeable.

i.e. the speed improvement of the caching would vary by the details of the hardware and OS used. If your OS is leading to excessive memory usage (for whatever reason), that would likely decrease the performance.

al20878 commented 2 years ago

Thanks. Meanwhile, I tried to use procmon and the latest just refuses to run on Win 7, popping a message that it's unable to load a driver :-( Well, too bad.

al20878 commented 2 years ago

BTW, dropping the cache size from (default) 5120 to 0 had the expected effect, as described earlier in this thread.

tustin2121 commented 2 years ago

I'm experiencing this issue too. Annoyingly, VSCode seems to also want to open 4-6 servers, and thus all 64gb of my virtual memory is suddenly used up for seemingly no reason.

I'll admit, I will be very glad if this is what's been causing my computer's memory problems recently -- VSCode crashing with the below error at semi-regular intervals, and other entirely unrelated programs like Chrome and Discord getting killed by the OS randomly. I was worried that my computer's physical memory had been damaged somehow. And I know the computer is old, but this seemed excessively bad for it. image

EDIT: Rolling all the way back to version 1.7.1 seems to make the cpptools-srv.exe processes actually behave themselves.

benj5378 commented 2 years ago

This is an issue on Ubuntu 22.04 too. Seeing 5+ cpptools-srv allocating huge amounts of memory.

AndreKR commented 2 years ago

@benj5378 I don't think it should be treated as a the same bug on Linux because Linux has memory overcommit, so in general allocating huge amounts of memory isn't a problem on Linux at all unless those memory pages are actually written to.

benj5378 commented 2 years ago

@AndreKR It's big enough that it makes my computer completely freeze for 5-10 minutes, before I can get to close VSCode.

Since I wrote my last message, it actually happened. I had just 3 cpp files open and 8gb ram + 2 gb swap has been eaten completely up. This time, it didn't just freeze, Ubuntu crashed!

And in any case, would this be a seperate bug (if even considered a bug)?

sean-mcmanus commented 2 years ago

@benj5378 Yes, your issue is different. The original issue is Win 7 specific and repros with any source file and is related to memory mapping with virtual alloc. Your issue may just be high memory usage for certain TU files -- the issue https://github.com/microsoft/vscode-cpptools/issues/9798 is tracking a similar issue in regards to the C_Cpp.maxMemory-related settings potentially not working (you could set those to non-default values and that could be a potential workaround).

HamAndEggs commented 2 years ago

I am seing similar issues. Closed down all browsers and all VSC instances. This code was still running hammering my CPU and eating ram. This is on Ubuntu 22.04 with 12th gen Intel. 64GB ram.

sean-mcmanus commented 2 years ago

@HamAndEggs Which process is using CPU/memory? If for some reason our cpptools process doesn't exit right after VS Code shutdown, it should exit after 5 minutes if VS Code is closed, so you might just need to wait longer. The original issue is an issue with Win7 and virtual memory so your Linux issue is different.

wj5449 commented 1 year ago

cpptools-srv.zip

this minidump from process explorer i have the same problem but don't know what happens, any one can use this to explain what happen?

kutukvpavel commented 1 year ago

For me the issue became progressively more consistent as the time passed. An 8Gb commit appears not long after I open any C/C++ project. Even with 16Gb of RAM now, this is pretty annoying, and hinders my work productivity, so I had to just move to Linux.

I might utilize process explorer now, though.

lohralfen commented 1 year ago

For me, this issue causes a complete freeze of my VirtualBox VM (Windows 10 Host, Ubuntu 20.04 Guest) as it seems to use way too much memory. The screenshot is technically before the crash occurs so you don't actually see the swap overflow.

I can reproduce it by doing the following:

  1. Keep Visual Studio Code open in background with a decently big project loaded
  2. Compile the code of the project that Visual Studio Code has open outside of Visual Studio Code (command line in my case) Each time these steps are performed, more and more memory is used until the VM hangs during a build and does not recover.

image

ropieur commented 1 year ago

I am facing the exact same issue with vscode 1.75.1 under ubuntu 22.04. It eats up to 15Gb. Are there settings to limit the memory usage of cpptools ?

sean-mcmanus commented 1 year ago

@ropieur You can try C_Cpp.maxMemory. Other settings might work depending on if cpptools is using the memory or child cpptools-src processes.

tshcherban commented 8 months ago

@sean-mcmanus C_Cpp.maxMemory does not help, still uses 8gb virtual memory.