PHP Read Library generation XML file Solution

Source: Internet
Author: User
PHP read library generate XML file
There are more than 60 W records in the library, and we use Php+mysql to cycle through the library to generate an XML file.
Now you are ready to save 1000 records per XML page, which is to generate more than 60 pages of XML files.

Now the problem: every time the XML file is generated to 13 pages is read in the library 134,000, the page error:
Fatal error:allowed memory size of 134217728 bytes exhausted (tried to allocate)

Ask Daniel to help you see what's going on here? What to do with it? How to get him through all the pages
I wish the good people a safe life!


------Solution--------------------
Allocated memory is not enough, modify php.ini find memory_limit = 128M change a little
------Solution--------------------
The memory limit for memory_limit settings in the php.ini configuration file is exceeded (the default value is 128mb,134217728 bytes). 128 trillion is enough, I guess your code has a problem, the loop is every 1000 records saved to a variable? You can instead save every 1000 variables to a PHP variable, then write an XML file, read 1000 variables, save to the same variable, and then write the XML file ...
------Solution--------------------
Memory exceeds the limit, you can try to control the memory limit in the high php.ini.
It is best to increase the number of cyclic reads, and unset () Mysql_free_result () frees the unwanted memory at the end of each loop
------Solution--------------------
Send the key code up to see.
------Solution--------------------
discuss
OK, is there any other way to do this if you don't change the server configuration file?

------Solution--------------------
discuss

Memory exceeds the limit, you can try to control the memory limit in the high php.ini.
It is best to increase the number of cyclic reads, and unset () Mysql_free_result () frees the unwanted memory at the end of each loop

------Solution--------------------
There's not enough memory, Bai.
The method is:
1. Increase the memory Ini_set the program can use (' Memory_limit ', '??? M ');
2. Reduce the memory that the program has used to see your code
------Solution--------------------
If I'm not mistaken, it should be more than 600 pages.
Use Mysql_free_result () to release the result set instead of the MySQL connection, release 10 pages once, and don't believe it.
------Solution--------------------
As long as there is no problem with the data itself, read and write in batches should be fine. If the server has restrictions and cannot modify the parameters, you can download the data back to local processing.
discuss

Reference:
If I'm not mistaken, it should be more than 600 pages.
Use Mysql_free_result () to release the result set instead of the MySQL connection, release 10 pages once, and don't believe it.
Brother, you're right. It's 600 pages, but Big Brother, are you sure you can make it?

------Solution--------------------
discuss
Now the problem: every time the XML file is generated to 13 pages is read in the library 13,000, the page error:
Fatal error:allowed memory size of 134217728 bytes exhausted (tried to a ...

------Solution--------------------
Put the code on it, and look.
------Solution--------------------
Another possible scenario is that the average length of the records returned by your query database is quite large (for example, the average total length of records exceeds 120KB). You can try to replace mysql_query with Mysql_unbuffered_query.
------Solution--------------------
discuss
504 Gateway Time-out

--------------------------------------------

nginx/0.6.35

------Solution--------------------
504 Gateway time-out is out of time
Not PHP timeout, but nginx timeout. Because you haven't had echo in the process.

DOMDocument Very memory consumption
Not suitable for your application
You can post the XML structure to see that it could be assembled in SQL

------Solution--------------------
About 504 Gateway time-out you can look at these http://www.google.com.hk/search?client=aff-cs-360chromium&ie=UTF-8&q=504+ Gateway+time-out
There's no need to argue with you.

Since it's a server, I don't have permission, so it doesn't matter. The command line executed the
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.