Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
916 views
in Technique[技术] by (71.8m points)

php - Fatal error: Out of memory (allocated 1134559232) (tried to allocate 32768 bytes) in X:wampwwwxxx

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:

Fatal error: Out of memory (allocated 1134559232) (tried to allocate 32768 bytes) in x:wampwwwxxx

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. :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...