Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP内存泄漏问题_Php_Apache_Memory Leaks - Fatal编程技术网

PHP内存泄漏问题

PHP内存泄漏问题,php,apache,memory-leaks,Php,Apache,Memory Leaks,我使用下面的脚本 <?php set_time_limit(0); if(isset($_GET['videoURL']) && $_GET['videoURL']!=''){ $URL=$_GET['videoURL']; $URL=base64_decode($URL); //clear all previous buffers start a new one ob_end_clean( ); ob_start( ); //

我使用下面的脚本

<?php
set_time_limit(0);
if(isset($_GET['videoURL']) && $_GET['videoURL']!=''){
    $URL=$_GET['videoURL'];
    $URL=base64_decode($URL);

    //clear all previous buffers start a new one
    ob_end_clean( ); ob_start( );

    // open file
    $handle = @fopen($URL, 'rb'); 

    // Forward headers, $http_response_header is populated by fopen call
    foreach ($http_response_header AS $header) {
        header($header);
    }

    //send header information
    ob_clean(); flush(); 

    $chunksize = 8*1024;

    $buffer = ''; 
    while (!feof($handle) ) { 
      $buffer= @fread($handle,$chunksize); 
      print $buffer;
      ob_flush(); 
      flush(); 
    } 
    fclose($handle); 
    exit;
}
?>

向用户流式传输视频。apache2进程运行正常,直到一个进程突然开始填充RAM并导致服务器崩溃

我不确定,但我相信它的内存泄漏问题。若我使用PID终止进程,那个么一切都会再次变得平滑,否则服务器就会停止

请在这方面帮助我

Apache配置:

<IfModule mpm_prefork_module>
    StartServers          1
    MinSpareServers       1
    MaxSpareServers      20
    MaxClients           256
   MaxRequestsPerChild  10
</IfModule>

<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      5
    MaxSpareThreads      25
    ThreadLimit          10
    ThreadsPerChild      10
    MaxClients           112
    MaxRequestsPerChild   5
</IfModule>

StartServers 1
MinSpareServers 1
MaxSpareServers 20
MaxClients 256
MaxRequestsPerChild 10
StartServers 2
Minspare5
MaxSpareThreads 25
螺纹极限10
螺纹锉刀10
MaxClients 112
MaxRequestsPerChild 5

错误日志说明了什么?首先,去掉“@”操作符。如果您想知道发生了什么,请不要禁止显示错误消息。@ShivanRaptor错误日志不显示任何内容。该进程占用指向该服务器的内存crashes@MikeW谢谢我会的,但问题似乎不在于fopen是否工作!对吧?我知道这个问题很老了。但对于其他人,设置内存分析器,从.htaccess、php.ini或其他地方检查php内存集。每个子级的Apache max请求可以将内存使用限制为mpm common的硬限制。