{"id":85929,"date":"2020-05-15T17:02:48","date_gmt":"2020-05-15T09:02:48","guid":{"rendered":"http:\/\/4563.org\/?p=85929"},"modified":"2020-05-15T17:02:48","modified_gmt":"2020-05-15T09:02:48","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88-php-%e8%84%9a%e6%9c%ac%e8%bf%90%e8%a1%8c%e7%9a%84%e5%86%85%e5%ad%98%e9%99%90%e5%88%b6%e6%9c%80%e5%b0%8f%e6%98%af-2m-%e5%91%a2%ef%bc%9f-memory_limit-%e5%8f%82%e6%95%b0","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=85929","title":{"rendered":"\u4e3a\u4ec0\u4e48 PHP \u811a\u672c\u8fd0\u884c\u7684\u5185\u5b58\u9650\u5236\u6700\u5c0f\u662f 2M \u5462\uff1f memory_limit \u53c2\u6570\u5df2\u7ecf\u8bbe\u7f6e\u4e3a 1M"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4e3a\u4ec0\u4e48 PHP \u811a\u672c\u8fd0\u884c\u7684\u5185\u5b58\u9650\u5236\u6700\u5c0f\u662f 2M \u5462\uff1f memory_limit \u53c2\u6570\u5df2\u7ecf\u8bbe\u7f6e\u4e3a 1M               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ligthdawn <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u9644\u4e0a\u811a\u672c<\/p>\n<pre><code>&lt;?php  ini_set('memory_limit', '1M'); file_get_contents(\"\/data\/www\/elasticsearch-7.4.2-linux-x86_64.tar.gz\"); <\/code><\/pre>\n<p>\u8bfb\u53d6\u7684\u6587\u4ef6 elasticsearch-7.4.2-linux-x86_64.tar.gz 200 \u591a M<\/p>\n<p>\u62a5\u9519\u4fe1\u606f\u5982\u4e0b PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 288783720 bytes)<\/p>\n<p>\u7591\u95ee\uff0c\u4e3a\u4ec0\u4e48\u8bbe\u7f6e\u4e86\u811a\u672c\u8fd0\u884c\u7684\u5185\u5b58\u9650\u5236\u4e3a 1M\uff0c\u4f46\u662f\u62a5\u9519\u4fe1\u606f\u662f\u663e\u793a 2M \u5462<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1504709\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CodeCodeStudy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             PHP \u91c7\u53d6\u201c\u9884\u5206\u914d\u65b9\u6848\u201d\uff0c\u63d0\u524d\u5411\u64cd\u4f5c\u7cfb\u7edf\u7533\u8bf7\u4e00\u4e2a chunk \uff08 2M\uff0c\u5229\u7528\u5230 hugepage \u7279\u6027\uff09\uff0c\u5e76\u4e14\u5c06\u8fd9 2M \u5185\u5b58\u5207\u5272\u4e3a\u4e0d\u540c\u89c4\u683c\uff08\u5927\u5c0f\uff09\u7684\u82e5\u5e72\u5185\u5b58\u5757\uff0c\u5f53\u7a0b\u5e8f\u7533\u8bf7\u5185\u5b58\u65f6\uff0c\u76f4\u63a5\u67e5\u627e\u73b0\u6709\u7684\u7a7a\u95f2\u5185\u5b58\u5757\u5373\u53ef<\/p>\n<p>https:\/\/segmentfault.com\/a\/1190000014764790                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1504710\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CodeCodeStudy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/github.com\/php\/php-src\/blob\/master\/Zend\/zend_alloc.c#L2660<\/p>\n<p>ZEND_API int zend_set_memory_limit(size_t memory_limit)<br \/>{<br \/>#if ZEND_MM_LIMIT<br \/> AG(mm_heap)-&gt;limit = (memory_limit &gt;= ZEND_MM_CHUNK_SIZE) ? memory_limit : ZEND_MM_CHUNK_SIZE;<br \/>#endif<br \/> return SUCCESS;<br \/>}<\/p>\n<p>\u8bf4\u660e memory_limit \u662f\u6709\u6700\u5c0f\u503c\u9650\u5236\u7684                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1504711\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CodeCodeStudy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/github.com\/php\/php-src\/blob\/master\/Zend\/zend_alloc_sizes.h#L22<\/p>\n<p>#define ZEND_MM_CHUNK_SIZE (2 * 1024 * 1024) \/* 2 MB *\/                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1504712\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : ligthdawn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @CodeCodeStudy \u8c22\u8c22\u8001\u54e5\uff0c\u4eca\u5929\u65e9\u4e0a\u521a\u521a\u627e\u5230\u7c7b\u4f3c\u7684\u6587\u7ae0 https:\/\/blog.csdn.net\/IT_10\/article\/details\/94768679                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48 PHP \u811a\u672c\u8fd0\u884c\u7684\u5185\u5b58\u9650\u5236&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85929"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85929"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85929\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85929"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}