search
HomeBackend DevelopmentPHP TutorialHow to solve the File size limit exceeded error_PHP tutorial

How to solve the File size limit exceeded error_PHP tutorial

Jul 21, 2016 pm 03:06 PM
filelimitsizeyiiusemethodframeofwritesolvemeetmistakequestion

I encountered a problem yesterday. I used the Yii framework to write a php script to export more than 1 million data in the db and run it successfully.

But when running to the 490,000th item, the script terminated and prompted the error "File size limit exceeded", so I googled it and found that the size of a certain file exceeded the system limit. The author's first reaction was that the log file was full? ? ? I quickly checked the log and found that it was only a few dozen K!!! So where is this "big file"?

Starting the analysis, it cannot be a problem with the Yii framework. This is an abnormal problem of the Linux operating system and the framework is dull, nor is it the size of the log file. I carefully checked the files under all the set log paths. They are all small and can be ignored. Even if Yii debug is turned off, the same problem occurs.

Then change the idea, re-run the script, run the script again, and find that the dead time is very regular. It all hangs up when there are 450,000 records, one is no more and one is less. I begin to suspect that it is related to the process. Decided to view the io affected by the script process.

1. First get the of the script process;

2. Use the lsof command to check the io status of this pid: lsof -p

A suspected file data0/xdebug/cachegrind.out. was found. As the script was executed, the size of the xdebug file also increased. Finally, as expected, it died! The file size at this time is: 2147483647! !

Haha, such a familiar number, 2^31 -1! !

It seems that the problem has been found. When the script is executed, xdebug also writes and records the log of the script process. When the file size exceeds the file size that the system can support, it hangs as expected.

ok, turn off xdebug and re-run the script. More than one million records have been successfully run. Done.

ps: The server I am using is a 32-bit system, and in a 32-bit operating system, because it is binary, the maximum data it can store is 1111111111111111111111111111111.

Because of this, the decimal notation reflected in other visual systems is 2147483647.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327621.htmlTechArticleI encountered a problem yesterday. I used the Yii framework to write a php script to export more than 1 million data in the db and run it. ,success. But when running to the 490,000th item, the script terminates, prompting the error "...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.