Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

The default memory limit of php-language-server fails on 32bit PHP on Windows, worth mentioning in the README? #16

Closed
Dragory opened this issue Sep 13, 2017 · 6 comments

Comments

@Dragory
Copy link

Dragory commented Sep 13, 2017

php-language-server sets memory_limit to 4G by default if --memory-limit isn't specified. This becomes 2MB on 32bit PHP, at least on Windows, and throws a Fatal Error when the language server tries to load stubs. However, this fails silently, since ide-php doesn't listen to the language server's stdout. The issue can be fixed by either upgrading to 64bit PHP or specifying a --memory-limit less than 4G when starting the language server.

My suggestions:

  1. Either specify 64bit in the README, or set --memory-limit to e.g. "2G" when running php-language-server
  2. Listen to the language server's output (childProcess.stdout.on('data', ...)) and log it for easier debugging of similar errors in the future
@damieng
Copy link
Contributor

damieng commented Sep 13, 2017

We can definitely specify a memory limit - probably a good idea to make it configurable too.

The language server should not be outputting errors on stdout - that channel is used for JSON RPC communication in stdio mode and messages not in that JSONRPC format will cause errors.

Might be worth running it always in socket mode to avoid such a problem (we do this on Windows)

@damieng
Copy link
Contributor

damieng commented Sep 13, 2017

Do you have a link to more information on this? While I can add a configuration switch I would also like it to work out-the-box on Windows x86 and x64. Are you sure the 32-bit x86 is 2MB? Or did you mean 2GB?

@Dragory
Copy link
Author

Dragory commented Sep 13, 2017

No, I just know that when php-language-server set memory_limit to 4G on 32bit PHP, the error said Allowed memory size of 2097152 bytes exhausted, which is 2MB. It's possibly a fallback of some sort?

However, the max memory_limit for 32bit PHP is probably 2GB ("2G").

@damieng
Copy link
Contributor

damieng commented Sep 13, 2017

Right the max memory limit defaults to 4GB or 2GB depending on 64-bit or 32-bit.

Not sure why php-language-server would interfere with this.

@Dragory
Copy link
Author

Dragory commented Sep 13, 2017

Not sure, but they do this at the beginning of their code, which attempts to set it to 4GB regardless of 32/64bit:

image
(https://github.com/felixfbecker/php-language-server/blob/master/bin/php-language-server.php#L7)

Not sure why it would fall back to 2MB, though - I couldn't find any info on that by googling.

@damieng
Copy link
Contributor

damieng commented Sep 14, 2017

New 0.6.2 package has an setting where you can configure the memory limit. I've also reported this to the language-server team so hopefully they'll address it there too.

@damieng damieng closed this as completed Sep 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants