I created an artisan command that will execute a large query that will save the result to a table so it will be rendered faster fetching from the stored table.
Upon running the command, after long minutes, error messages started to appear.
VirtualAlloc() failed: [0x00000008] Not enough storage is available to process this command.
VirtualFree() failed: [0x000001e7] Attempt to access invalid address.
When I limit the query (e.g. TOP(5)) it didn't occur the error.
Sample query:
SET NOCOUNT ON
SET QUOTED_IDENTIFIER OFF
SET ARITHABORT OFF
SET ANSI_WARNINGS OFF
SET ANSI_NULLS OFF
SELECT DISTINCT
*
FROM DB1.dbo.Table1 a
JOIN DB2.dbo.Table2 b on a.someid=b.externalid
OPTION(recompile)
In Console/Commands:
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$sQuery = SQLScript::call('pqa_vintage'); // This calls the sql file
$aResult = DB::connection('sqlsrv_1')->select(DB::raw($sQuery));
Model::truncate();
// Saving to the table
}
Environment:
XAMPP
Windows 10
PHP 7
MSSQL 2014
Update
Upon checking the PHP error log:
[11-Dec-2017 19:49:23 Timezone] PHP Fatal error: Out of memory (allocated 1478492160) (tried to allocate 4096 bytes) in C:\[path_to_project]\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php on line 142
[11-Dec-2017 19:49:23 Timezone] PHP Fatal error: Out of memory (allocated 1478492160) (tried to allocate 32768 bytes) in C:\[path_to_project]\vendor\symfony\debug\Exception\FatalErrorException.php on line 1
php.ini config:
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit=10000M
User contributions licensed under CC BY-SA 3.0