- Code: Select all
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 4096 bytes) in C:\Users\Username\Desktop\site\DocumentRoot\test.php on line 1.
I am running XAMPP (version 7.0.18) on a Windows 10 machine. The path for the “DocumentRoot” folder is set in the httpd.conf file:
- Code: Select all
DocumentRoot "C:\Users\Username\Desktop\site\DocumentRoot"
<Directory "C:\Users\Username\Desktop\site\DocumentRoot">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
I created a simple test case with a “test.php” file and a “test-process.php” file. The “test.php” file has the following code (in its entirety):
- Code: Select all
<?php include 'test-process.php'; ?>
The “test-process.php” file has the following code (in its entirety):
- Code: Select all
<?php
$output['message'] = 'Hello World';
echo json_encode($output);
?>
The following include_path is set in the php.ini file:
- Code: Select all
include_path = ".;c:\Users\Username\Desktop\site\includes"
Removing/renaming the PHP file from the includes folder and removing/renaming the includes folder itself have no effect on the error. I would expect to see some error stating that the file or directory could not be found, but there is none.
I tried using "include_once" (instead of "include") in the "test.php" file and no errors are given. So perhaps the "Allowed memory size..." error is caused from attempting to repeatedly include the "test-process.php" file.
I am new to XAMPP and cannot figure this out. Although I haven’t tried this exact situation on a production server, I have used AJAX in the past with no such issues on production servers. Any suggestions would be appreciated.