致命错误:允许的内存大小为268435456字节耗尽(尝试分配4294967296字节)

时间:2022-03-18 11:04:29

I am receiving the following error on a script when it reaches the bind section of this code.

当脚本到达此代码的绑定部分时,我在脚本上收到以下错误。

Error:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4294967296 bytes)

致命错误:允许的内存大小为268435456字节耗尽(尝试分配4294967296字节)

Code:

$result = $dbc->prepare('SELECT make, line, model, name, year, image, processor_family, processor_speeds, shipped_ram, max_ram, ram_type, video_card, video_memory, screen_type, screen_size, hard_drives, internal_drives, external_drives, audio_card, speakers, microphone, networking, external_ports, internal_ports, description, driver_link, manufacturer_link FROM laptop_archive where name=?');

$result->bind_param('s', $name);

$result->execute();

$result->bind_result($make, $line, $model, $name, $year, $image, $processor_family, $processor_speeds, $shipped_ram, $max_ram, $ram_type, $video_card, $video_memory, $screen_type, $screen_size, $hard_drive, $internal_drives, $external_drives, $audio_card, $speakers, $microphone, $networking, $external_ports, $internal_ports, $description, $driver_link, $manufacturer_link);

The portion of the database that it is attempting to access has a number of fields to retrieve although none of them contain a large amount of data with the majority being around 20 characters and the description at around 300 characters.

它试图访问的数据库部分有许多要检索的字段,尽管它们都不包含大量数据,其中大部分数据大约为20个字符,描述大约为300个字符。

I have had a search which reveals a few answers although none of them have worked for me, the code is running on a VPS with 512MB RAM and has a memory limit of 256MB as set in php.ini.

我有一个搜索,它显示了一些答案,虽然它们都没有为我工作,代码运行在具有512MB RAM的VPS上,并且内存限制为256MB,如php.ini中所设置的。

The amount of memory to be allocated is 4GB which seems extremely excessive for what is in the database, am I missing something stupid here.

要分配的内存量是4GB,这对于数据库中的内容来说似乎非常过分,我在这里错过了一些愚蠢的东西。

3 个解决方案

#1


0  

normal times it shouldnt take any huge memory because you didnt fetch the data.

正常时间它不应该占用任何巨大的内存,因为你没有获取数据。

$res = $mysqli->query("SELECT * FROM laptop_archive where name=[REPLACE THIS] limit 1")#
$res->fetch_assoc()

please try this one :)

请试试这个 :)

#2


0  

The issue appears to be caused by the use of LONGTEXT in the database, after changing the type to VARCHAR the issue has gone away.

该问题似乎是由于在数据库中使用LONGTEXT引起的,在将类型更改为VARCHAR后问题已经消失。

#3


0  

I had this error two days ago. From what I have learned about it the problems lies in the size of the column your selecting from. In my case I was selecting a pdf and I had to column as a long blob which is 4294967296 bytes. The server was allocating that much to grab the file regardless of the size of the file. So I had to change the column to a medium blob and it works fine. So in your case it looks like it would be the image. I would change that to a medium blob and it should work fine. Otherwise you would have to configure your server to allow bigger allocations of grabs.

我两天前有这个错误。根据我所了解的,问题在于您选择的列的大小。在我的情况下,我选择了一个pdf,我必须列为长blob,这是4294967296字节。无论文件大小如何,服务器都会分配那么多来获取文件。所以我不得不将列更改为中等blob并且工作正常。所以在你的情况下,它看起来像是图像。我会把它改成一个中等blob,它应该工作正常。否则,您必须配置服务器以允许更大的抓取分配。

#1


0  

normal times it shouldnt take any huge memory because you didnt fetch the data.

正常时间它不应该占用任何巨大的内存,因为你没有获取数据。

$res = $mysqli->query("SELECT * FROM laptop_archive where name=[REPLACE THIS] limit 1")#
$res->fetch_assoc()

please try this one :)

请试试这个 :)

#2


0  

The issue appears to be caused by the use of LONGTEXT in the database, after changing the type to VARCHAR the issue has gone away.

该问题似乎是由于在数据库中使用LONGTEXT引起的,在将类型更改为VARCHAR后问题已经消失。

#3


0  

I had this error two days ago. From what I have learned about it the problems lies in the size of the column your selecting from. In my case I was selecting a pdf and I had to column as a long blob which is 4294967296 bytes. The server was allocating that much to grab the file regardless of the size of the file. So I had to change the column to a medium blob and it works fine. So in your case it looks like it would be the image. I would change that to a medium blob and it should work fine. Otherwise you would have to configure your server to allow bigger allocations of grabs.

我两天前有这个错误。根据我所了解的,问题在于您选择的列的大小。在我的情况下,我选择了一个pdf,我必须列为长blob,这是4294967296字节。无论文件大小如何,服务器都会分配那么多来获取文件。所以我不得不将列更改为中等blob并且工作正常。所以在你的情况下,它看起来像是图像。我会把它改成一个中等blob,它应该工作正常。否则,您必须配置服务器以允许更大的抓取分配。