De PHP language server is using huge amounts of memory when inspecting my project.

Currently 45GB (after that i killed it)

It's only with a specific project (See composer file), so not a generic issue.

anyone an idea how to debug this, to see what's going wrong here?

Project is basically a standard project
https://github.com/squizlabs/PHP_CodeSniffer + https://github.com/slevomat/coding-standard
without any further modifications

Composer.json

{
    "name": "squizlabs/php_codesniffer",
    "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
    "type": "library",
    "keywords": [
        "phpcs",
        "standards",
        "static analysis"
    ],
    "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
    "license": "BSD-3-Clause",
    "authors": [
        {
            "name": "Greg Sherwood",
            "role": "lead"
        }
    ],
    "support": {
        "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
        "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki",
        "source": "https://github.com/squizlabs/PHP_CodeSniffer"
    },
    "extra": {
        "branch-alias": {
            "dev-master": "3.x-dev"
        }
    },
    "require": {
        "php": ">=5.4.0",
        "ext-tokenizer": "*",
        "ext-xmlwriter": "*",
        "ext-simplexml": "*",
        "slevomat/coding-standard": "^8.6"
    },
    "require-dev": {
        "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
    },
    "bin": [
        "bin/phpcs",
        "bin/phpcbf"
    ],
    "config": {
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true
        }
    }
}

To me the issue is being the CPU but could be similar in bigger projects (I mean 45GBs is a lot lol)

But my problem is with this extension indexing stuff that shouldn't index (even if being ignored, don't know how to really ignore some paths recursively)

    Hi, thank you for the detailed information.

    It is actually NOT using 45G of memory, the virtual memory address space is only reserved by the process. We'll try to avoid that, but it should not cause any issues on your system.

    This is briefly explained on https://github.com/dotnet/runtime/issues/7740 for more details.

      2 months later
      • Edited

      I've got the same problem with huge memory usage, the project has just a default Drupal CMS installation, but devsense.php.ls eats 9 Gb of RAM.

      Is there any tools to get more detailed report about memory usage, to debug the issue?

      I'm dealing with a similar problem.
      I have a new laravel project, completely empty for now, and the php extension is making it impossible to work.
      Even after a few hours, it seems to keep scanning the project and never ends.
      My VSCode was recently freshly installed, keeps saying 'processing ... ' and never finish. And goes until a certain number of 'files' processed and stays there.

      And the devsense.php.ls process is using a lot of cpu and memory:

      I don't know what else to do, I can't work like this ...

        MauroSassaroli thanks - we'll work on it, there are a few issues on Mac now. Here, we're probably incorrectly processing hidden files and directories.

          4 days later

          pre-release 1.25.11728 improves the memory efficiency, we'd appreciate it if you'll try it and let us know if it helps.

          Although; it doesn't fix the problem of thousands of files being (unnecessarily) parsed.

            3 months later

            JurgenMahn @MauroSassaroli @d8vjork @Murz

            Thank you all for your feedback! and sorry for the inconvenience.

            We have released Pre-Release 1.32.12908 which fixes the memory leak. It was happening every time a .phar file was added/updated within the workspace.

            Please update to the pre-release. It should improve memory usage significantly. We'll keep working on improving memory usage continuously.

            a year later

            Hi,
            I'm having same issue on Visual Code server on Ubuntu Server machine.
            PHP devsense extesions takes up to 13++GB of ram.
            Consider that I'm co-working on a Prestashop project (there's large amount number of files)
            The machine has 16GB total ram, but it's dedicated to only this project.
            It saturates the RAM and SWAP, then freezing machine that needs to be manually rebooted.
            I was forced to disable the extension in order to continue working on the project.
            Is there a way to limit the ram usage of your extension?

            Versions I'm using: VS Code 1.89.1, PHP devsense 1.46.15409, Ubuntu server 22.04.4 LTS

              MicheleDiana Thank you for posting the issue.

              13 GB is way too much. Does it happen gradually during your work or quickly (5 minutes) after opening a workspace?

                JakubMisek On Ubuntu server, with VS Code server off, there's 3GB occupied. Then I start on my client the remote SSH connection, and it starts filling RAM. The process that occupies memory is the devsense php vscode extension. It fills until RAM saturates. Like getting all space available. I've rebooted server multiple times, nothing changed. If I kill the process from machine terminal, then the RAM drop down to 3/4GB instantly, then after a few seconds the process is restarted and goes back to occupying all the available RAM as before (like a keep alive feature). The only way to overcome this behavior is to disable the extension. I've even tried to uninstall and install all devsense extesions again (server side and client side), but nothing changed.

                  MicheleDiana Thank you for the details.

                  It may be caused by the amount of files being loaded to RAM (but it would have to be a million files) ...

                  So it's probably a bug :/ We'll try Prestashop ... is there anything specific to the project we should try?

                    JakubMisek Maybe not million, but there's lots of files... little files, but many of them. Consider that the core uses Symfony, and there's lots of dependencies.
                    No, I've encountered RAM issue even on fresh installation, without working on it.
                    I haven't told you that, like in the screenshot shared by Mauro Sassaroli on this thread, on startup it processes a number of files very big, and it keep processing for like 1 min.

                      9 days later

                      MicheleDiana the latest update (1.47) improves the RAM use. We'll keep working on it.

                        2 months later

                        Here is happening the same, just with Drupal and Prestashop projects.

                          In my case, the current drupal Project is using about 2Gb, can't take more because Docker + Chrome are using the rest of RAM and Swap is full and hangs up.