php-language-server icon indicating copy to clipboard operation
php-language-server copied to clipboard

Cpu load, memory leak

Open pakulin opened this issue 8 years ago • 24 comments
trafficstars

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 ](url)

pakulin avatar Aug 22 '17 05:08 pakulin

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.

venatiodecorus avatar Aug 25 '17 14:08 venatiodecorus

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

alancd avatar Sep 15 '17 10:09 alancd

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

felixfbecker avatar Sep 18 '17 20:09 felixfbecker

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

alancd avatar Sep 20 '17 10:09 alancd

dependencies are cached

felixfbecker avatar Sep 20 '17 14:09 felixfbecker

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

coderNeos avatar Dec 11 '17 02:12 coderNeos

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

catroll avatar Dec 26 '17 02:12 catroll

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

jens1o avatar Dec 26 '17 10:12 jens1o

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?

felixfbecker avatar Dec 26 '17 11:12 felixfbecker

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

phil-nelson avatar Dec 26 '17 11:12 phil-nelson

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

jens1o avatar Dec 26 '17 12:12 jens1o

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

d0niek avatar Jun 11 '18 09:06 d0niek

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

harmboschloo avatar Jun 15 '18 05:06 harmboschloo

Is this still happening?

felixfbecker avatar Nov 11 '18 19:11 felixfbecker

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

lracicot avatar Jan 21 '19 18:01 lracicot

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)

emilisev avatar Jan 25 '19 16:01 emilisev

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

maras3000 avatar Apr 29 '19 12:04 maras3000

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

philoSurfer avatar Aug 01 '19 17:08 philoSurfer

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.

valeryan avatar Aug 22 '19 14:08 valeryan

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

redpawn96 avatar May 17 '20 12:05 redpawn96

Still having this issue:

OS: Mac OS 10.15 Extension version: 2.3.14

abhisheksoni27 avatar May 21 '20 06:05 abhisheksoni27

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

hadesunseenn avatar Dec 01 '20 21:12 hadesunseenn

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

mfuery avatar Sep 13 '21 16:09 mfuery

thanks @mfuery , did not notice

hadesunseenn avatar Sep 13 '21 20:09 hadesunseenn