5

When i run bellow code from php-fpm:

$connect = new PDO("dblib:host=mssql.dev.gm.local;dbname=GeoData","username","password");

try{
    $s = $connect->query('[RU].GetTownInfo 4368');
    var_dump($s->fetch());
}catch (Exception $e){
    var_dump($e->getMessage());
}

I get Exception:

PDOExeption SQLSTATE[HY001] Unable to allocate sufficient memory

But when i run the same code from php command line, i don't have such problems.

What can be the problem?

I use nginx proxy_pass to backend(php-fpm).

To connect to MS SQL Server i use Dblib (freetds). All works in one machine with OpenVZ, Nginx and Php-fpm are different virtual-machines.

Php-fpm config for command-line and upstream are the same.

iusik
  • 86
  • 7
  • The problem presumably comes from the php-sql extension. Inspect difference in configuration between php-fpm.ini and php-cli.ini – twicejr Nov 21 '16 at 13:15
  • Perhaps increasing the php memory limit? ini_set('memory_limit','-1'); – Harold Scholtz Nov 21 '16 at 13:15
  • You can also monitor your memory processes on the server while you're running the script. Maybe you are actually running out of memory and swap. – aynber Nov 21 '16 at 13:19
  • Changing memory_limit does not help. There is up-to 8Gb free memory. – iusik Nov 21 '16 at 13:20
  • 2
    The error message is very missleading. If you have a look into sybase and Microsoft docs regarding ODBC, the exception can be caused by problematic ODBC drivers, trying to fetch unavailable objects, querying unavailable stuff,.... it does not need to have something to do with memory. Try to update your ODBC and libraries. – Daniel W. Nov 21 '16 at 15:21
  • Have you seen this doc? `https://learn.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/resolve-out-of-memory-issues?view=sql-server-ver15` – Dhananjay Kyada Feb 02 '21 at 12:11

1 Answers1

0

The system tells you the problem right?

PDOExeption SQLSTATE[HY001] Unable to allocate sufficient memory

So you could try to give php some more memory by changing the limit in php.ini:

memory_limit = 128M

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Jamie
  • 91
  • 1
  • 12
  • 1
    `memory_limit` does not magically solve all memory errors. Raising it merely fixes the problems caused by itself, which are by the way clearly reported as such. – Álvaro González Nov 21 '16 at 15:13
  • Furthermore, I'm pretty sure the memory limit of PHP (-scripts) do not concern the memory a third party extension is consuming. – Daniel W. Nov 21 '16 at 15:26