Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cpu load, memory leak #465

Open
pakulin opened this issue Aug 22, 2017 · 24 comments
Open

Cpu load, memory leak #465

pakulin opened this issue Aug 22, 2017 · 24 comments

Comments

@pakulin
Copy link

pakulin commented Aug 22, 2017

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)

@venatiodecorus
Copy link

venatiodecorus commented Aug 25, 2017

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
Copy link

alancd commented Sep 15, 2017

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

@felixfbecker
Copy link
Owner

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
Copy link

alancd commented Sep 20, 2017

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

@felixfbecker
Copy link
Owner

dependencies are cached

@coderNeos
Copy link

coderNeos commented Dec 11, 2017

+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
Copy link

catroll commented Dec 26, 2017

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
Copy link
Contributor

jens1o commented Dec 26, 2017

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

@felixfbecker
Copy link
Owner

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
Copy link
Contributor

phil-nelson commented Dec 26, 2017

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
Copy link
Contributor

jens1o commented Dec 26, 2017

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

@d0niek
Copy link

d0niek commented Jun 11, 2018

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
Copy link

harmboschloo commented Jun 15, 2018

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
Copy link
Owner

Is this still happening?

@lracicot
Copy link

lracicot commented Jan 21, 2019

It is still happening. I came from atom/ide-php#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
Copy link

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
Copy link

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

@philoSurfer
Copy link

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
Copy link

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
Copy link

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
Copy link

Still having this issue:

OS: Mac OS 10.15
Extension version: 2.3.14

@hadesunseenn
Copy link

hadesunseenn commented Dec 1, 2020

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
Copy link

mfuery commented Sep 13, 2021

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

@hadesunseenn
Copy link

thanks @mfuery , did not notice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests