由于未知原因,我的php脚本已循环并占用所有可用的物理内存
我已经将内存限制从1GB增加到2GB。 我的php.ini文件由于未知原因,我的php脚本已循环并占用所有可用的物理内存,php,loops,memory,time,Php,Loops,Memory,Time,我已经将内存限制从1GB增加到2GB。 我的php.ini文件 memory_limit = 2G upload_max_filesize = 2G post_max_size = 2G max_execution_time = 1500 max_input_vars = 10000 suhosin.post.max_vars = 10000 suhosin.request.max_vars = 10000 suhosin.get.max_value_length = 10000
memory_limit = 2G
upload_max_filesize = 2G
post_max_size = 2G
max_execution_time = 1500
max_input_vars = 10000
suhosin.post.max_vars = 10000
suhosin.request.max_vars = 10000
suhosin.get.max_value_length = 10000
suhosin.request.max_varname_length = 35000
但当我运行PHP脚本时,会出现以下错误:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in /home/givezuya/public_html/includes/system/Exceptions.php on line 47
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in /home/givezuya/public_html/includes/Common.php on line 204
Exceptions.php中的第47行:
if (is_cli()) {
Common.php中的行号204:
if (isset($last_error) && $last_error["type"] & (1 | 4 | 16 | 32 | 64 | 128)) {
实际上我想打开联系人页面。
我的联系人页面的链接是:
contact.php的完整代码
<?php
if (!defined('EvolutionScript'))
die('Hacking attempt...');
// Help desk//
$helpdesk = new \Evolution\Models\Helpdesk();
if (!$helpdesk->isOnline()) {
redirect();
}
if ($input->get('t') == 'new') {
$captcha = \Evolution\Components\Captcha::load('contact');
if ($input->post('do') == 'submit') {
$form_validation = new \Evolution\Components\Form_validation();
if (!$user->isOnline()) {
$form_validation->set_rules('name', 'name', 'required', [
'required' => lang('enter_full_name')
]);
$form_validation->set_rules('email', 'email', 'required|valid_email', [
'required' => lang('enter_email'),
'valid_email' => lang('enter_valid_email')
]);
}
$form_validation->set_rules('department', 'department', 'required|is_natural_no_zero', [
'required' => lang('select_department'),
'is_natural_no_zero' => lang('select_department')
]);
$form_validation->set_rules('subject', 'subject', 'required', [
'required' => lang('enter_subject'),
]);
$form_validation->set_rules('message', 'message', 'required', [
'required' => lang('enter_message'),
]);
if (!csrf_validation()) {
$error_msg = lang('invalidtoken');
} elseif (!$captcha->validate()) {
$error_msg = lang('invalidimageverification');
} elseif ($form_validation->run() == false) {
$error_msg = validation_errors();
} elseif (!$helpdesk->validate_department($input->post('department'))) {
$error_msg = lang('select_department');
} else {
$helpdesk->create_ticket();
$session->set_flashdata('form_success', lang('ticketsent'));
redirect(current_url());
}
}
$template->display('helpdesk_open.tpl', [
'error_msg' => isset($error_msg) ? $error_msg : null,
'captcha' => $captcha
]);
}
if ($input->get('view_ticket')) {
if ($user->isOnline()) {
if (!$ticket = $helpdesk->getRow(['ticket' => $input->get('view_ticket'), 'user_id' => $user->get('id')])) {
redirect('?view=contact');
}
} else {
if (!$ticket = $helpdesk->getRow(['ticket' => $input->get('view_ticket')])) {
redirect('?view=contact');
}
if (!$session->has_userdata('ticket_id') || $session->userdata('ticket_id') != $ticket->id) {
redirect('?view=contact');
}
}
if ($input->post('do') == 'reply') {
$form_validation = new \Evolution\Components\Form_validation();
$form_validation->set_rules('message', 'message', 'required', [
'required' => lang('enter_message')
]);
if (!csrf_validation()) {
$error_msg = lang('invalidtoken');
} elseif ($ticket->status == 4) {
$error_msg = lang('invalidrequest');
} elseif ($form_validation->run() == false) {
$error_msg = validation_errors();
} elseif (!$helpdesk->user_reply($ticket->id, $ticket->status)) {
$error_msg = lang('wait_to_replyticket');
} else {
$session->set_flashdata('form_success', lang('msgsent'));
redirect(current_url());
}
}
$template->display('helpdesk_view.tpl', [
'error_msg' => isset($error_msg) ? $error_msg : null,
'ticket' => $ticket
]);
}
if ($user->isOnline()) {
$template->display('helpdesk_user.tpl', [
'pagination' => $helpdesk->user_tickets($user->get('id'))
]);
} else {
if ($input->post('do') == 'view_ticket') {
include_once BASEPATH . 'Sources/ticket.php';
$form_validation = new \Evolution\Components\Form_validation();
$form_validation->set_rules('ticketid', 'ticketid', 'required|alpha_dash');
$form_validation->set_rules('email', 'email', 'required|valid_email');
if (!csrf_validation()) {
$error_msg = lang('invalidtoken');
} elseif ($form_validation->run() == false) {
$error_msg = lang('ticket_not_found');
} elseif (!$ticket = $helpdesk->getRow(['ticket' => $input->post('ticketid'), 'email' => $input->post('email')])) {
$error_msg = lang('ticket_not_found');
} else {
$session->set_userdata('ticket_id', $ticket->id);
redirect('?view=contact&view_ticket=' . $ticket->ticket);
}
}
$template->display('helpdesk_home.tpl', [
'error_msg' => isset($error_msg) ? $error_msg : null
]);
}
帮我解决这个严重的问题。我已经尝试了所有可能的方法,但无法解决此问题。好的,假设您的第一个
if
中有错误
这里我添加了一些die
命令(现在它们被注释了)
联合国逐一发表评论。因此,从die('1')
开始。如果您取消对这行的注释,您将在页面上看到“1”。如果是,则删除此die('1')
命令(或对其进行注释)。继续新的
问题是这段代码没有可疑的部分,所以很难说到底哪个块是坏的——我们需要找到那个块
//die('1');
如果($input->get('t')=='new'){
//死亡('3');
$captcha=\Evolution\Components\captcha::load('contact');
如果($input->post('do')==“提交”){
//死亡('6');
$form_validation=new\Evolution\Components\form_validation();
如果(!$user->isOnline()){
$form\u validation->set\u规则('name'、'name'、'required'[
'必需'=>lang('输入全名')
]);
$form_validation->set_规则('email'、'email'、'required | valid_email'[
'required'=>lang('enter_email'),
'valid\u email'=>lang('enter\u valid\u email')
]);
}
//死亡('7');
$form_validation->set_rules('department'、'department'、'required';is_natural_no_zero'[
'required'=>lang('select_department'),
'is_natural_no_zero'=>lang('select_department')
]);
$form\u validation->set\u规则('subject'、'subject'、'required'[
'required'=>lang('enter_subject'),
]);
$form\u validation->set\u规则('message'、'message'、'required'[
'required'=>lang('enter_message'),
]);
//死亡('8');
如果(!csrf_validation()){
$error_msg=lang('invalidtoken');
}elseif(!$captcha->validate()){
$error_msg=lang('invalidimageverification');
}elseif($form\u validation->run()==false){
$error\u msg=验证错误();
}elseif(!$helpdesk->validate_department($input->post('department')){
$error_msg=lang('select_department');
}否则{
$helpdesk->create_ticket();
$session->set_flashdata('form_success',lang('ticketsent');
重定向(当前url());
}
}
//死亡('4');
$template->display('helpdesk\u open.tpl'[
'error\u msg'=>isset($error\u msg)?$error\u msg:null,
“验证码”=>$captcha
]);
//死亡('5');
}
//死亡('2');
最后,你会看到一个屏幕上显示的
die
命令列表,以及一个不起作用的列表(例如,可能是1,2,3-你看到了它们,但是4,5,6,7,8-它们都会导致内存崩溃)我不知道,但是如果(isset($last_error)&$last_error[“type”]&(1 | 4 | 16 | 32 | 128)){
对我来说似乎无效。这两个代码块无法创建异常,因为它们是异常处理程序,所以它们只是对导致内存泄漏的某些内容作出反应。它可以位于代码=)的任何位置,但您可以尝试从Exceptions.php向我们显示更多行,它是is_cli
function@Anton请结帐。我已经准备好了有问题的完整Exceptions.php文件。如果你想要任何其他代码,请告诉我。@GrumpyCrouton你能检查更多并给我有效的代码吗?我只是复制粘贴你的代码并按照你的指示。完成所有这些之后,我只得到了1和2。@SayedHossain我必须说的是令人震惊的结果。因为在1和3之间有一行:If($input->get('t')=='new'){
那里没有任何东西可以使用所有的内存…当然我们可以深入了解$input
对象及其get
方法,但是…发生的一切都很奇怪。这很奇怪。除了占用所有可用内存之外,还有其他问题吗?实际上我已经应用了几乎所有的方法修复“错误503”但无法解决此问题。我的主机提供商名为廉价。他们100%向我保证cpanel配置没有问题。那么问题出在哪里?什么?什么?真的很奇怪。@SayedHossain您可以尝试在代码中找到类似于$input=
,因此创建$input
的位置。我认为这是一个wrapper用于GET和POST参数…因此您还可以尝试将comments.php
替换为:
It takes all available physical memory for some reason.I would advice contacting a web developer for assistance.this case requires advance knowledge in the sphere of the web development.