PHP卷曲,使用CURLOPT_SSL_VERIFYPEER时发生内存泄漏,为true [英] PHP curl, memory leak when using CURLOPT_SSL_VERIFYPEER, true

查看:79
本文介绍了PHP卷曲,使用CURLOPT_SSL_VERIFYPEER时发生内存泄漏,为true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cloudfusion已经有一段时间了,需要切换到较新版本的AWS sdk并遇到内存泄漏.据报告,内存泄漏已使用了大约一年,但没有真正的解决方案.经过大量阅读,运行测试和调查结果之后,以下简单的守护程序重现了该问题

I have been using cloudfusion for quite a while and needed to switch to the newer version AWS sdk and ran into memory leaks. The memory leak has been reported for about a year, without a real solution. After a lot of reading, running tests and investigating results the following simple daemon reproduces the issue

#! /usr/bin/env php
<?php class httpsTest{
    function curlHttps($memLeak=false){
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, 'https://sqs.us-east-1.amazonaws.com');
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $memLeak);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_exec($curl);
        curl_close($curl);
    }
}
gc_enable();
$myPid = getmypid();$i=0;
$test  = new httpsTest();
while ($test){
    $test->curlHttps(true);
    echo $i++ ." PHP Info MemUsage: ".memory_get_usage() ."    Linux Info ";
    system('cat /proc/' .$myPid .'/status|grep '.'"VmSize"');
    sleep(1);
}

因此,当使用值为true的CURLOPT_SSL_VERIFYPEER时,每18次迭代将泄漏132 KB.为了确保我不打败老家伙,fedora 14系统已用php 5.3.10,libcurl 7.24.0.-1.0,nss-3.12.10-7,openssl-1.0.0e-1更新.

So when using the CURLOPT_SSL_VERIFYPEER with value true it leaks 132 kbytes every 18 iterations. To make sure I'm not beating a dead horse the fedora 14 system has been updated with php 5.3.10, libcurl 7.24.0.-1.0, nss-3.12.10-7, openssl-1.0.0e-1.

我无法想象以前没有人遇到过这种情况,尽管当您仅依靠php内存报告时看起来一切都很好.可以肯定的是,我已将其报告给php专家,但是php似乎做得对,并且泄漏是在使用的库中造成的.

I cannot imagine that no one has ran into this before although it looks all fine when you just rely on the php memory reporting. To be sure I have reported it to the php experts, but it looks like php is doing it right and the leak is created in the used libraries.

我该怎么做才能收集有用的信息以解决此问题,我检查了泄漏的堆,并清楚地看到了泄漏情况和无泄漏情况的区别.在泄漏的情况下,堆的顶部充满了16个字节的对象,这些对象的地址进一步变空.因此,看来对象已被清空但没有释放.

What could I do to collect useful information for getting this resolved, I checked the leaking heap and could clearly see a difference in the leaked and none leaked situation. In the leaked situation the top of the heap was filled with mostly 16 byte objects having an address while being further empty. So it looks like objects are being emptied but not released.

非常感谢您的任何建议

推荐答案

进行许多HTTPS连接时,该问题仍在发生.检查此 https://bugs.php.net/bug.php?id=76542

The issue is still happening when doing many HTTPS connections. Check this out https://bugs.php.net/bug.php?id=76542

粘贴到curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

这篇关于PHP卷曲,使用CURLOPT_SSL_VERIFYPEER时发生内存泄漏,为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆