felixfbecker / php-language-server

PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥
ISC License
1.16k stars 185 forks source link

Cpu load, memory leak #465

Open pakulin opened 7 years ago

pakulin commented 7 years ago

mac sierra Code 1.15.1 Php instellisense 1.15.0 php 7.1.6_18

Cpu load 95% with no tabs opened, memory usage gradually increased by 1-2 mb in 10 secs Maybe this will help: [php_intellisense_1.5.0.txt](https://github.com/felixfbecker/php-language-server/files/1240892/php_intellisense_1.5.0.txt)

venatiodecorus commented 7 years ago

I also see a PHP process start and utilize a full core of my CPU as soon as I open VSCode.

OSX 10.12.5 VSCode 1.15.1 PHP Intellisense 1.5.1

EDIT: Err, it seems to be gone now. I saw it running for a while last night, maybe it just took a while to scan my current project? It is rather large.

alancd commented 7 years ago

"All 8812 PHP files parsed in 492 seconds. 160 MiB allocated"

felixfbecker commented 7 years ago

What is the bug here? The language server needs to build it's index the first time when it's not cached, it's expected that this takes some CPU and RAM

alancd commented 7 years ago

It looks like there's no caching, and every time you open a project with VS CODE, a parsing process is opened.

felixfbecker commented 7 years ago

dependencies are cached

coderNeos commented 6 years ago

+1 i have the same problem. Everytime i relaunch Vscode, parsing starts from begining and dependencies are not cached - it may be because i have 2 separate folders and each of them has one composer.lock file. Also i have large php projects where i don't use composer so all files are parsed on start. It would be nice to manually specify which files should be cached.

catroll commented 6 years ago

Ubuntu 17.10 VS Code 1.19.1 PHP Intellisense 2.2.2 Memory Size: 16G, almost used by a process called "PHP Language Server"

$ ps -ef | grep -E "9099|6596"
catroll   6596  6541  1 09:50 ?        00:00:07 /usr/share/code/code --nolazy --inspect=9333 /usr/share/code/resources/app/out/bootstrap --type=extensionHost
catroll   6629  6596  1 09:50 ?        00:00:04 /usr/share/code/code /usr/share/code/resources/app/extensions/html/node_modules/vscode-languageclient/lib/utils/electronForkStart /usr/share/code/resources/app/extensions/html/server/out/htmlServerMain.js --node-ipc --clientProcessId=6596
catroll   9302  6596 99 09:56 ?        00:00:19 PHP Language Server
catroll   9364  5172  0 09:57 pts/0    00:00:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn -E 9099|6596
jens1o commented 6 years ago

I'm seeing this too, even when launching simple projects.

felixfbecker commented 6 years ago

Could you try setting COMPOSER_ALLOW_XDEBUG=1 with XDebug on, then see if the language server crashes with a max recursion limit reached error?

phil-nelson commented 6 years ago

I have found a bug with the recent foreach handling, this is a case that causes an infinite loop:

$a = [];
foreach ($a as $k => $a) {
}

I have a fix but it's not very nice yet, working on it.

@jens1o you say the project you're seeing this on is simple, can you confirm if you have something like the above?

Another example is

foreach ($a->getArray() as $k => $a) {
}

Edit: to be clear, the issue I'm seeing occurs when you overwrite the variable being iterated with the foreach value, in the cases above, $a

jens1o commented 6 years ago

Yes, it has. It really looks like an infinite loop.

d0niek commented 6 years ago

I have the same problem, PHP Language Server consume 100% cpu and Load average is +10. How can I debug was is going on? The worst is that when I close Atom, PHP Language Server is still running..

harmboschloo commented 6 years ago

I also have a continuous high cpu on windows running with vscode. After vscode closes the process remains with high cpu and I have to kill it manually.

image

edit: cpu load and memory usage are stable remaining at ~34% and ~115Mb

felixfbecker commented 5 years ago

Is this still happening?

lracicot commented 5 years ago

It is still happening. I came from https://github.com/atom/ide-php/issues/108 and I had to disable the atom extension because of the high CPU usage.

screen shot 2019-01-21 at 13 05 49

php-ide version: 0.7.18 OS: macOS Mojave

emilisev commented 5 years ago

Hi, I have the same issue with Windows 8.1, Atom 1.34, ide-php 0.7.18 PHP CLI remains even though I'm not doing anything in Atom and initialization is done 2019-01-25_1741 Also the initialization occurs each time I start Atom (about 25s)

maras3000 commented 5 years ago

Also having this problem on Ubuntu 18.04 + Atom and VS Code

philoSurfer commented 5 years ago

This is still happening with IDE-PHP atom extension.

A simple php file with php_info(); eats up a whole CPU indefinitely. php-language-server-cpu-load

valeryan commented 5 years ago

This may be related in some way to a bug I was having in my own extension. In my extension, I notice that php child processes were failing to be killed and continue to absorb memory and cpu power. I hacked around this on linux platforms by being really aggressive about killing child processes like this:

function phpCliKill(command: ChildProcess) {
    if (!/^win/.test(process.platform)) {
        exec(`ps -ef | awk '/phpcs/ {print $2" "$8" "$4" "$7}'`,
            (err, stdout) => {
                if (err) {
                    window.showErrorMessage('Sniffer: Error trying to kill PHP CLI, you may need to kill the process yourself.');
                }
                stdout.split("\n").forEach(($process) => {
                    const killable = $process.split(" ");
                    if (killable[1] === "php" && parseInt(killable[2]) > 90) {
                        exec(`kill ${killable[0]}`);
                    }
                });
            });
    }

    command.kill();
}

and then calling it on a timeout. setTimeout(() => !sniffer.killed && phpCliKill(sniffer), 3000);

I have not taken the time to develop a similar method for windows or see if this works on osx but I think.

Anyway I don't know if thats helpful, but it could be a similar problem.

redpawn96 commented 4 years ago

Still having issues on high memory consumption of the extension. Here is what process explorer looks even if I just open a workspace with one folder full of pure php files. vscode_process_explorer

abhisheksoni27 commented 4 years ago

Still having this issue:

OS: Mac OS 10.15 Extension version: 2.3.14

hadesunseenn commented 3 years ago

same issue for me Ubuntu Verison : 20.04 Vscode version: 1.51.1 Tried with the latest vscode extension

when installing PHP intelliSense or PHP intelephense the PHP language server starts using almost 100 percent CPU. So issue is not only with PHP intelliSense but also with PHP intelephense

mfuery commented 3 years ago

This project isn't maintained - last stable commit 3+ years ago. FWIW I switched to PHP Intelephense and that solved my problem.

hadesunseenn commented 3 years ago

thanks @mfuery , did not notice