dongpengqin3898 2015-01-21 13:22
浏览 353
已采纳

Guzzle:未捕获的异常和内存泄漏

I'm having weird issues while using Guzzle

When I try to simulate an erroneous request (e.g. a request which returns a status code 404) Guzzle throws a ClientException containing all the details of why that request failed.

When I try to catch this exception my script exits with a fatal error stating that I didn't catch the exception and it shows an XDebug trace stating that I had a memory leak somehow.

My code looks like this:
Note: httpClient is a valid instance of GuzzleHttp/CLient.

$request  = $this->httpClient->createRequest(
    'GET',
    '/templates/'.$id
);

try {
    $response = $this->httpClient->send($request);
} catch (\Exception $exception) {
    die('exception occured');
}

The error I end up with is the following:
Guzzle stack trace
Guzzle stack trace
Memory leak
Memory leak

Does someone have a suggestion to what might cause this uncaught exception + leak?

  • 写回答

1条回答 默认 最新

  • dsgm5631 2015-01-21 13:51
    关注

    Your XDebug wants to consume more memory than the defined limit

    Your limit is : 512MO for A Script
    Your XDebug wants to consume : 652MO

    You have 2 solutions to resolve this technical issue
    1 - Update your php.ini => memory_limit = 768M and after that restart your server
    2 - In your PHP script put this line code on top :

    ini_set("memory_limit","768M");
    

    Now you must be completely sure that this memory leak will not happend in your production environment, by disabling XDebug

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?