dongyukui8330 2009-06-10 07:27
浏览 34

如何在Apache + PHP + Win2k3中查找和修复memleaks

Alright folks,

We've got Apache 2.2.11 running mod_php 5.2.9-2 on a Windows Server 2003 (Small Business Edition) box, and each request spikes somewhere around 4 to 8MB of RAM, followed by approximately 2 to 6MB of freeing. Basically, the amount Apache releases is always notably less (by megabytes) than the amount it allocates during the request, and after a few hours the httpd.exe process ends up consuming all available RAM and the server hangs.

This behaviour doesn't occur at all on our Windows XP development boxes with the same codebase and following configs:

  • XP/Apache 2.2.11/PHP5.2.9-2/MySQL 5.1.34
  • XP/Apache 2.0.x (various)/PHP5.2.7/MySQL 5.0.67

Simple PHP scripts on the production server (Win2k3) don't appear to leak e.g:

  • Basic PHP echo functions
  • Creating and referencing classes
  • Output buffering
  • PDO with and without persistent connections

When running our full app, however, things start to leak. The only things we can think of that would cause this are the use of objects, session details, global variables - but how can I find out what the leak is? And what's causing it? Without disrupting too much the only machine we can duplicate the issue on??

  • 写回答

1条回答 默认 最新

  • dongmu7335 2009-06-10 07:37
    关注

    PHP has it's own memory functions, and you can create __destroy magic functions to monitor objects. I personally would make a testing copy, make a few edits so you can monitor ram and see where it increases or decreases.

    Personally I would have first assumed it was a caching issue, with the ram increasing, but if it renders the system unstable then it is clearly not so easy.

      echo "Before SomeStrangeObject == ".memory_get_usage()."<br>";
      $x = new SomeStrangeObject();
      echo "During SomeStrangeObject == ".memory_get_usage()."<br>";
      unset($x);
      echo "After SomeStrangeObject == ".memory_get_usage()."<br>";
    

    And just look for obvious leeks. Sorry I can't be any more helpfull.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大