<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head>
<card title="解决PHP curl 长时间运行 内存泄露问题的方法（curl访问https站点时有bug）" id="card1">
<p> 游客</p><p>
标题:解决PHP curl 长时间运行 内存泄露问题的方法（curl访问https站点时有bug）<br/>
正文:<br/>
php curl使用privoxy代理访问https://www.google.com/search?q=xxxcurl配置平淡无奇，长时间运行发现一个严重问题，内存泄露！不论用单线程和多线程都无法避免！是curl访问https站点的时候有bug！内存泄露可以通过linux的top命令发现，使用php函数memory_get_usage()不会发现。经过反复调试找到解决办法，curl配置添加如下几项解决问题： 代码如下: [CURLOPT_HTTPPROXYTUNNEL] = true; [CURLOPT_SSL_VERIFYPEER] = false; [CURLOPT_SSL_VERIFYHOST] = false;CURLOPT_HTTPPROXYTUNNEL具体说明stackoverflow上有，直接贴原文：Without CURLOPT_HTTPPROXYTUNNELWithout CURLOPT_HTTPPROXYTUNNEL : You just use the proxy address/port as a destination of your HTTP request. The proxy will read the HTTP headers of your query, forward your request to the destination (with your HTTP headers) and then write the response to you.Example steps :1）HTTP GET /index.html sent to 1.1.1.1 (proxy)2）1.1.1.1 receive request and parse header for getting the final destination of your HTTP request.3）1.1.1.1 forward your query and headers to www.site.com (destination in request headers).4）1.1.1.1 write back to you the response receive from www.site.comWith CURLOPT_HTTPPROXYTUN<br/><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2098&amp;Page=1">[&lt;&lt;]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2098&amp;Page=1">[[1]]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2098&amp;Page=2">[2]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2098&amp;Page=3">[3]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2098&amp;Page=3">[&gt;&gt;]</a><br/>
<br/>
<a href="wap.asp?act=Com&amp;id=2098">查看评论(0)</a><br/>
<a href="wap.asp?act=AddCom&amp;inpId=2098">发表评论</a><br/><br/>

<br/>

<br/>
<a href="http://camnpr.com/wap.asp">首页</a>
</p>
</card>
</wml>