致命错误:X:wampwwwxxx 中的内存不足(已分配 1134559232)(试图分配 32768 字节)

2023-10-11php开发问题
0

本文介绍了致命错误:X:wampwwwxxx 中的内存不足(已分配 1134559232)(试图分配 32768 字节)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在个人 PC 上的本地主机上使用 WAMP 服务器(32 位).我有一个大(非常大)多维数组,它通过读取包含长句子的 CSV 文件(CSV 文件包含 20,000 行信息)来获取其信息.问题是我在进行一些计算时收到以下错误:

I am using WAMP server(32 bits) on local host on my personal PC. I have a big (very big) multidimensional array which gets its information by reading a CSV file which contains long sentences(the CSV file contains 20,000 row of information). The problem is that I get the following error when it goes through some calculations:

致命错误:内存不足(已分配 1134559232)(尝试分配32768 字节)在 x:wampwwwxxx

我尝试了不同的解决方案,例如增加 upload_max_filesizepost_max_sizemax_file_uploadsmemory_limit 或将其设置为 -1在 php.ini 或我的脚本开头也没有人工作.请帮助我,请不要让我重新构建我的代码或更改 WAMP 的版本,由于某些原因这是不可能的.非常感谢你.:)

I tried different solutions like increasing upload_max_filesize, post_max_size , max_file_uploads and memory_limit or set it to -1 in php.ini or at the beginning of my scripts also, no one works. Please help me, and please do not ask me to re-architect my codes or change the version of WAMP, due to some reasons it is not possible. Thank you very much. :)

推荐答案

我终于找到了解决方案.我发现当PHP收集垃圾越来越满时,没有办法释放它.Unsetgc_collect_cycles() 也无效.唯一的方法是在不同的代码段上使用Function.就我而言,我在 for 循环中有一个大脚本,所以我将所有代码复制到一个函数中,并在我的循环中调用该函数.每次函数安静时,内存就会得到释放.您可以通过在函数中添加一次 memory_get_usage() 并在函数外添加一次来测试它以查看差异.

Finally I could find the solution. I found that when the PHP collection garbage is getting full, there is no way to free it. Unset and gc_collect_cycles() also are not effective. The only way is to use Function over different section of codes. In my case, I had a big script in a for loop, so I copied all my codes in a function, and in my loop I call the function. Each time function quiets, memory gets free. You may test it by adding memory_get_usage() once in your function and once out of the function to see the difference.

这篇关于致命错误:X:wampwwwxxx 中的内存不足(已分配 1134559232)(试图分配 32768 字节)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17