|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-05-19 11:37 UTC] cmb@php.net
-Type: Bug
+Type: Feature/Change Request
[2021-05-19 11:37 UTC] cmb@php.net
[2021-06-08 14:16 UTC] nikic@php.net
-Status: Open
+Status: Wont fix
[2021-06-08 14:16 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 18:00:01 2025 UTC |
Description: ------------ Currently, PDO Sqlite in memory database ignores memory_limit which is dangerous as system's memory can be exhausted by a single script. PDO Sqlite should allocate memory using PHP allocation routines so the memory is counted and limited. Test script: --------------- <?php var_dump(memory_get_usage()); var_dump(memory_get_usage(true)); echo "\n"; for ($i = 0; $i < 3; $i++) { $db = new PDO('sqlite::memory:'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->exec('CREATE TABLE foo (bar TEXT)'); for ($j = 0; $j < 20; $j++) { $db->exec("INSERT INTO foo (bar) VALUES ('" . bin2hex(random_bytes(2 * 1024 * 1024)) . "')"); } var_dump(memory_get_usage()); var_dump(memory_get_usage(true)); $db->exec('DROP TABLE foo'); $db = null; var_dump(memory_get_usage()); var_dump(memory_get_usage(true)); echo "\n"; } Expected result: ---------------- memory_get_usage includes memory allocated by sqlite and memory_limit is honored Actual result: -------------- int(351144) int(2097152) int(351536) int(2097152) int(351176) int(2097152) int(351536) int(2097152) int(351176) int(2097152) int(351536) int(2097152) int(351176) int(2097152)