致命错误:X:\ wamp \ www \ xxx中的内存不足(已分配1134559232)(试图分配32768字节) [英] Fatal error: Out of memory (allocated 1134559232) (tried to allocate 32768 bytes) in X:\wamp\www\xxx

查看:57
本文介绍了致命错误:X:\ wamp \ www \ xxx中的内存不足(已分配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)(试图分配 x:\ wamp \ www \ xxx

Fatal error: Out of memory (allocated 1134559232) (tried to allocate 32768 bytes) in x:\wamp\www\xxx

我尝试了不同的解决方案,例如增加upload_max_filesizepost_max_sizemax_file_uploadsmemory_limit,或者在php.ini或脚本的开头将其设置为-1,也没人能用.请帮助我,并且由于某些原因,请不要要求我重新构造代码或更改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()并在函数中添加一次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:\ wamp \ www \ xxx中的内存不足(已分配1134559232)(试图分配32768字节)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆