{"id":2788,"date":"2012-05-04T10:32:52","date_gmt":"2012-05-04T15:32:52","guid":{"rendered":"http:\/\/icesquare.com\/wordpress\/?p=2788"},"modified":"2012-05-04T10:33:46","modified_gmt":"2012-05-04T15:33:46","slug":"phpfatal-error-allowed-memory-size-of-x-bytes-exhausted-tried-to-allocate-y-bytes","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/phpfatal-error-allowed-memory-size-of-x-bytes-exhausted-tried-to-allocate-y-bytes\/","title":{"rendered":"[PHP]Fatal error: Allowed memory size of x bytes exhausted (tried to allocate y bytes)"},"content":{"rendered":"<p><\/p>\n<p><img decoding=\"async\" data-attachment-id=\"1813\" data-permalink=\"https:\/\/icesquare.com\/wordpress\/how-to-setup-tftp-on-ubuntu\/tftp-title\/#main\" data-orig-file=\"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2011\/11\/tftp-title.jpg\" data-orig-size=\"373,155\" data-comments-opened=\"1\" data-image-title=\"tftp-title\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2011\/11\/tftp-title.jpg\" src=\"\/wordpress\/wp-content\/uploads\/2011\/12\/computer-problem.jpg\" alt=\"\" title=\"tftp-title\" class=\"alignleft size-thumbnail wp-image-1813\"\/><\/p>\n<div style=\"margin-bottom:30px;\"><\/div>\n<p>A user complained to me that my PHP web applications stopped working today. After I digged into the error log, I found that following message:<\/p>\n<pre>\r\nPHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to allocate 261900 bytes) in Unknown on line 0\r\n<\/pre>\n<p>Obviously, this is related to the memory error. Therefore I tried to increase the limit of memory_limit in php.ini. Since I have 8G of memory in my box, I think it is okay to set the memory limit of PHP to 4GB.<\/p>\n<pre>\r\n;memory_limit = 128M\r\nmemory_limit = 4096M\r\n<\/pre>\n<p>When I restart the Apache\/PHP, I found another nightmare. My web application stopped working! When the user tries to access http:\/\/mywebsite\/index.php, instead of rendering the code, the browser kept prompting the user to download the file.<\/p>\n<p>After scratching my head for a while, I found that I missed something, which is very very important. I was running XAMPP (32-bit) on a Fedora 64-bit machine. See the problem? Since XAMPP is running in 32-bit, it does not understand what is 4096 MB. (If you install 4GB of memory in any Windows 32-bit machine, you will notice that Windows can only allocate 3GB of them, and the 1GB left memory is sitting inside your computer and doing nothing&#8230;) Therefore, I decrease the memory_limit to 2048MB, and that solved the problem.<\/p>\n<p>Time to move away from XAMPP.<\/p>\n<p>&#8211;Derrick<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A user complained to me that my PHP web applications stopped working today. After I digged into the error log, I found that following message: PHP Fatal error: Allowed memory <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/phpfatal-error-allowed-memory-size-of-x-bytes-exhausted-tried-to-allocate-y-bytes\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[94,10,6,69],"tags":[172],"class_list":["post-2788","post","type-post","status-publish","format-standard","hentry","category-computer-problems-computer-help-pc-support","category-php","category-technology","category-troubleshooting-technology","tag-php"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-IY","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3495,"url":"https:\/\/icesquare.com\/wordpress\/xampp-php-fatal-error-class-ziparchive-not-found\/","url_meta":{"origin":2788,"position":0},"title":"XAMPP &#8211; PHP Fatal error:  Class &#8216;ZipArchive&#8217; not found","author":"Derrick","date":"March 11, 2014","format":false,"excerpt":"I just finished writing a program written in PHP today. When I moved to the another environment, I found that the script didn't work. After some investigations, I found that the program stopped running because of the following error: PHP Fatal error: Class 'ZipArchive' not found in ... The error\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/03\/xampp-logo.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":462,"url":"https:\/\/icesquare.com\/wordpress\/tornado-web-very-fast\/","url_meta":{"origin":2788,"position":1},"title":"Tornado Web Server &#8211; Very Fast!","author":"Derrick","date":"November 29, 2009","format":false,"excerpt":"I just did a benchmark comparison on Tornado Web Server and Apache + PHP server. The result is pretty amazing. What to test: A simple Hello World application. How: ab -n 1000 -c 300 http:\/\/myserver.ip Test Environment OS: FreeBSD 7.1 CPU: Pentium III 933 MHz Ram: 256 MB PHP: 5.2.9\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2646,"url":"https:\/\/icesquare.com\/wordpress\/php-imagecreatefrompng-error\/","url_meta":{"origin":2788,"position":2},"title":"[PHP]imagecreatefrompng Error (After upgrading FreeBSD)","author":"Derrick","date":"January 25, 2012","format":false,"excerpt":"Today, I found that one of my PHP scripts stop working. After some investigations, I found that it was the function, imagecreatefrompng, which caused the problem. Interestingly, other similar functions such as imagecreatefromgif and imagecreatefromjpeg were completely working fine. The program stopped working when calling imagecreatefrompng only. [ad#adbrite-square] Initially, I\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3134,"url":"https:\/\/icesquare.com\/wordpress\/php-network-error\/","url_meta":{"origin":2788,"position":3},"title":"PHP Network Error","author":"Derrick","date":"February 21, 2013","format":false,"excerpt":"One of my PHP web applications stopped working today. After I investigated the issues, I noticed that this is a very famous, yet unsolved error. I have no idea why it happens, but I do have a work around solution for it. Basically, this article applies to you if you\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2812,"url":"https:\/\/icesquare.com\/wordpress\/freebsdhow-to-run-pecl-tokyo-tyrant-in-php-5-4\/","url_meta":{"origin":2788,"position":4},"title":"[FreeBSD]How to run PECL Tokyo Tyrant in PHP 5.4","author":"Derrick","date":"May 19, 2012","format":false,"excerpt":"After upgrading to PHP 5.4.3 (which is the first version of PHP 5.4 available in the FreeBSD port), I found that the pecl-tokyo_tyrant could not be compiled. Here is the error messages: cd \/usr\/ports\/databases\/pecl-tokyo_tyrant sudo make ===> pecl-tokyo_tyrant-0.6.0 cannot install: doesn't work with PHP version : 5 (Doesn't support PHP\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2156,"url":"https:\/\/icesquare.com\/wordpress\/cant-connect-to-local-mysql-server-through-socket-varlibmysqlmysql-sock-2\/","url_meta":{"origin":2788,"position":5},"title":"Can&#8217;t connect to local MySQL server through socket &#8216;\/var\/lib\/mysql\/mysql.sock&#8217; (2)","author":"Derrick","date":"December 21, 2011","format":false,"excerpt":"When I tried to connect to the MySQL server through PHP, I got the following error: Can't connect to local MySQL server through socket '\/var\/lib\/mysql\/mysql.sock' (2) To give you some background, here is my situation. My Fedora Linux is a 64-bit machine, and I have installed a 32-bit version of\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/2788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2788"}],"version-history":[{"count":3,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/2788\/revisions"}],"predecessor-version":[{"id":2790,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/2788\/revisions\/2790"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}