목차
新闻" >/blog.php'">新闻
Quick links
Contactus
Aboutus
回复讨论(解决方案)
백엔드 개발 PHP 튜토리얼 网站出现内存用尽(error: Allowed memory size of 134217728 bytes exhausted (tried to all)

网站出现内存用尽(error: Allowed memory size of 134217728 bytes exhausted (tried to all)

Jun 23, 2016 pm 01:28 PM

出现问题:
[Thu Jul 09 09:57:22 2015] [error] [client 183.61.51.179] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes) in /vhost/vhostroot/wart8555/www/class/companyInfomation.php on line 80
[Thu Jul 09 09:57:48 2015] [error] [client 59.57.252.98] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes) in /vhost/vhostroot/wart8555/www/class/companyInfomation.php on line 80
[Thu Jul 09 09:57:50 2015] [error] [client 59.57.252.98] File does not exist: /vhost/vhostroot/wart8555/www/favicon.ico
[Thu Jul 09 10:01:38 2015] [error] [client 59.57.252.98] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes) in /vhost/vhostroot/wart8555/www/class/companyInfomation.php on line 80
首先index.php中引用foot.php页面,里面出现了问题,初学PHP,请大神帮忙看下

<?php  include 'include.php';include ROOT_PATH . '/tool/Page.php';include ROOT_PATH . '/tool/Database.php';include ROOT_PATH.'/class/baseProduct.php';include ROOT_PATH.'/class/baseInformation.php';//产品list$baseProduct = new BaseProduct();$productList = $baseProduct->indexShow();$information = new BaseInformation();$infor_list = $information->findPage(1, 5);?><!DOCTYPE html><head><title><?php echo WEB_TITLE;?></title><meta charset="UTF-8"><link rel="stylesheet" href="css/foundation.min.css"><link rel="stylesheet" href="css/superfish.css"><link rel="stylesheet" href="css/stylesheet.css"><link rel="stylesheet" href="js/slider/flexslider.css"><link rel="stylesheet" href="js/slider/flexcar.css"><link href='css/defult.css' rel='stylesheet' type='text/css'><script src="js/vendor/custom.modernizr.js"></script><script>Modernizr.load({    // test if browser understands media queries    test: Modernizr.mq('only all'),    // if not load ie8-grid    nope: 'css/ie8-grid-foundation-4.css'});</script><!--[if lt IE 9]><link rel="stylesheet" href="css/ie-fixes.css"><![endif]--></head><body><div class="header">  <?php include ROOT_PATH.'/top.php';?>  <div class="slider">      </div></div><div class="tagline">  <div class="row">    <div class="columns large-12">      <div class="center">		<div class="columns large-4 large-offset-1 content sidebar" id="youkuplayer" style="float: left; width: 370px;height: 241px; margin-left: 0"></div>		<script type="text/javascript" src="http://player.youku.com/jsapi">				player = new YKU.Player('youkuplayer',{				styleid: '0',				client_id: '9d672744e5e73950',				vid: 'XMTI3ODgyNjU4OA==',				autoplay: false,				show_related: false,				events:{					onPlayEnd: function(){ playVideo(); }					}				});				function playVideo(){					player.playVideo();					}			</script>		<div class="columns large-4 large-offset-1 content sidebar" style="float: left; margin-left: 10px;">        <h1 id="blog-php-新闻">/blog.php'">新闻</h1>        <ul>        <?php for($i=0;$i<count($infor_list);$i++){?>          <li class="bullet" style="text-align: left;"><a href="<?php echo ROOT_URL."/blog.php?id=".$infor_list[$i]["id"];?>"><?php echo $infor_list[$i]["title"].$infor_list[$i]["id"];?></a></li>        <?php }?>                  </ul>      </div>      <div></div>      </div>    </div>  </div></div><div class="service-box" style="display: none;">  <?php for($i=0;$i<count($productList);$i++){  		if($i==0){  			echo "<div class=\"row service\">";  		}elseif($i%3==0){  			echo "</div><div class=\"row service\">";  		}  		$picSrc = ROOT_URL.$productList[$i]["hostPath"]."/".$productList[$i]["saveName"];  ?>    <div class="columns large-4 sp">      <h1 class="service-subtitle sp_title"><?php echo $productList[$i]["title"];?></h1>      <p><img  src="/static/imghw/default1.png"  data-src="<?php echo $picSrc;? alt="网站出现内存用尽(error: Allowed memory size of 134217728 bytes exhausted (tried to all)" >"  class="lazy"   alt="" class="threeUp"></p>      <div> <?php echo $productList[$i]["littleContent"];?></div>      <p> <a class="button custom">详情</a> </p>    </div>  <?php if($i==count($productList)-1){  			echo "</div>";  		}  }?></div><div class="front-testimonial">  <div class="row">    <div class="columns large-12">      <div class="flexcar">          </div>  </div></div>  <?php include ROOT_PATH.'/foot.php';?><script src="js/jquery.min.js"></script><script src="js/hoverIntent.js"></script><script src="js/superfish.js"></script><script src="js/slider/jquery.flexslider.js"></script><script>Modernizr.load({    test: Modernizr.placeholder,    nope: 'js/placeholder.min.js'});function goToNewPage() {    if (document.getElementById('target').value) {        window.location.href = document.getElementById('target').value;    }}</script><script>$(document).ready(function () {    $('ul.sf-menu').superfish({        animation: {            height: 'show'        },        delay: 400    });    $("img.scrollToTop").click(function () {        $("html, body").animate({            scrollTop: 0        }, "slow");    });    $('.flexslider').flexslider();    $('.flexcar').flexslider();});</script></body></html>
로그인 후 복사

<?phprequire_once 'include.php';require_once  ROOT_PATH.'/class/companyInfomation.php';$companyInfo_foot = new CompanyInfomation();$info_foot = $companyInfo_foot->getContent();?><footer class="footer">  <div class="row">    <div class="columns large-12 footer-inner">      <div class="row">        <div class="columns large-4 useful-links">          <div>            <h2 id="Quick-nbsp-links">Quick links</h2>            <ul class="footer-list">              <li><a href="#">伟达</a></li>              <li><a href="#">新闻</a></li>              <li><a href="#">产品</a></li>              <li><a href="#">视频</a></li>              <li><a href="#">下载</a></li>            </ul>          </div>        </div>        <div class="columns large-4 contact">          <div>            <h2 id="Contactus">Contactus</h2>            <ul class="footer-list">              <li><span class="small-icon"><img  src="/static/imghw/default1.png"  data-src="<?php echo ROOT_URL;? alt="网站出现内存用尽(error: Allowed memory size of 134217728 bytes exhausted (tried to all)" >/images/address.png"  class="lazy"   alt=""></span><?php echo $info_foot==null?"":$info_foot->getAddr();?></li>              <li><span class="small-icon"><img  src="/static/imghw/default1.png"  data-src="<?php echo ROOT_URL;? alt="网站出现内存用尽(error: Allowed memory size of 134217728 bytes exhausted (tried to all)" >/images/phone.png"  class="lazy"   alt=""></span><?php echo $info_foot==null?"":$info_foot->getTel();?></li>              <li><span class="small-icon"><img  src="/static/imghw/default1.png"  data-src="<?php echo ROOT_URL;? alt="网站出现内存用尽(error: Allowed memory size of 134217728 bytes exhausted (tried to all)" >/images/fax.png"  class="lazy"   alt=""></span><?php echo $info_foot==null?"":$info_foot->getFx();?></li>              <li><span class="small-icon"><img  src="/static/imghw/default1.png"  data-src="<?php echo ROOT_URL;? alt="网站出现内存用尽(error: Allowed memory size of 134217728 bytes exhausted (tried to all)" >/images/email.png"  class="lazy"   alt=""></span><?php echo $info_foot==null?"":$info_foot->getEmail();?></li>            </ul>          </div>        </div>        <div class="columns large-4 about">          <div>            <h2 id="Aboutus">Aboutus</h2>            <p><img src="/static/imghw/default1.png"  data-src="images/about.png"  class="lazy"   alt=""></p>            <p>Placerat urna et tristique in! Scelerisque integer nisi pha sellus, nec phasellus arcualiquet etiam magna massa sit cursus adipiscing sed, nec? Aenean odio! Cumac dolor dapibus tincidunt lorem ipsum dolor sit esmet placerat urna et tristique in! Scelerisque integer nisi phasellus</p>          </div>        </div>      </div>    </div>  </div></footer><div class="credit-row">  <div class="row">    <div class="columns large-11 credit"></div>    <div class="columns large-1"> <img class="scrollToTop lazy"  src="/static/imghw/default1.png"  data-src="images/toparrow.png"   alt="" > </div>  </div></div>
로그인 후 복사
<?phpclass CompanyInfomation{	private $id;	private $infomation;	private $addr;	private $tel;	private $fx;	private $email;		function setId($id){		$this->id = $id;	}	function getId(){		return $this->id;	}	function setInfomation($infomation){		$this->infomation = $infomation;	}	function getInfomation(){		return $this->infomation;	}	function setAddr($addr){		$this->addr = $addr;	}	function getAddr(){		return $this->addr;	}	function setTel($tel){		$this->tel = $tel;	}	function getTel(){		return $this->tel;	}	function setFx($fx){		$this->fx = $fx;	}	function getFx(){		return $this->fx;	}	function setEmail($email){		$this->email = $email;	}	function getEmail(){		return $this->email;	}		function edit(){		$select_sql = "select id from company_information where id = ?";		$insert_sql = "insert into company_information (information,addr,tel,fx,email)values(?,?,?,?,?)";		$update_sql = "update company_information set information = ?,addr=?,tel=?,fx=?,email=? where id=?";		$database = new Database();		$conn = $database->getConn();		$stmt = $conn->prepare($select_sql); 		$stmt->bind_param('i',$this->id); 		$stmt->execute(); 		$stmt->bind_result($id);				$stmt_edit = null;		if($stmt->fetch()){			$stmt_edit = $conn->prepare($update_sql); 			$stmt_edit->bind_param("sssssi",$this->infomation,$this->addr,$this->tel,$this->fx,$this->email,$this->id);			$stmt_edit->execute();		}else{			$stmt_edit = $conn->prepare($insert_sql);			$stmt_edit->bind_param("sssss",$this->infomation,$this->addr,$this->tel,$this->fx,$this->email);			$stmt_edit->execute();		}		$stmt->close();		$stmt_edit->close();		$conn->close();	}		function getContent(){		$select_sql = "select id,information,addr,tel,fx,email from company_information limit 0,1";		$database = new Database();		$conn = $database->getConn();		$stmt = $conn->prepare($select_sql); 		$stmt->execute();		$stmt->bind_result($id,$information,$addr,$tel,$fx,$email);		$infomation_obj = null;		if ($stmt->fetch())		{			$infomation_obj = new CompanyInfomation();			$infomation_obj->setAddr($addr);			$infomation_obj->setEmail($email);			$infomation_obj->setFx($fx);			$infomation_obj->setId($id);			$infomation_obj->setInfomation($information);			$infomation_obj->setTel($tel);		}		$stmt->close();		$conn->close();		return $infomation_obj;	}}?>
로그인 후 복사


回复讨论(解决方案)

内存不足,在报错前那行,打印下所有变量、参数,是不是过大了。

哪个是 companyInfomation.php ?

看不出哪里需要 4G 的内存

没看到需要4G内存的地方。

哪个是 companyInfomation.php ?

看不出哪里需要 4G 的内存

最后一个是 

内存不足,在报错前那行,打印下所有变量、参数,是不是过大了。

第一个104行,第二个3-5行,第3个的80

没看到需要4G内存的地方。

数据库查询最多一条数据,没有数据也会报这样的错

虽然 bind_result 方法不需要参数变量事先存在,但是你还是先声明一下比较妥当
$id = $information = $addr = $tel = $fx = $email = ‘’;
$stmt->bind_result($id,$information,$addr,$tel,$fx,$email);

虽然 bind_result 方法不需要参数变量事先存在,但是你还是先声明一下比较妥当
$id = $information = $addr = $tel = $fx = $email = ‘’;
$stmt->bind_result($id,$information,$addr,$tel,$fx,$email);

还是不行

你试一下不用 bind_result 是怎样的

谢谢各位回答,字段类型设置错误,一个大文本字段设置成为最大字段,需要内存4G,换了就好了

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

11 최고의 PHP URL 쇼트너 스크립트 (무료 및 프리미엄) 11 최고의 PHP URL 쇼트너 스크립트 (무료 및 프리미엄) Mar 03, 2025 am 10:49 AM

종종 키워드와 추적 매개 변수로 혼란스러워하는 긴 URL은 방문자를 방해 할 수 있습니다. URL 단축 스크립트는 솔루션을 제공하여 소셜 미디어 및 기타 플랫폼에 이상적인 간결한 링크를 만듭니다. 이 스크립트는 개별 웹 사이트 a에 유용합니다

Instagram API 소개 Instagram API 소개 Mar 02, 2025 am 09:32 AM

Instagram은 2012 년 Facebook에서 유명한 인수에 이어 타사 사용을 위해 두 개의 API 세트를 채택했습니다. Instagram Graph API 및 Instagram Basic Display API입니다. 개발자는

Laravel의 플래시 세션 데이터로 작업합니다 Laravel의 플래시 세션 데이터로 작업합니다 Mar 12, 2025 pm 05:08 PM

Laravel은 직관적 인 플래시 방법을 사용하여 임시 세션 데이터 처리를 단순화합니다. 응용 프로그램에 간단한 메시지, 경고 또는 알림을 표시하는 데 적합합니다. 데이터는 기본적으로 후속 요청에만 지속됩니다. $ 요청-

Laravel Back End : Part 2, React가있는 React 앱 구축 Laravel Back End : Part 2, React가있는 React 앱 구축 Mar 04, 2025 am 09:33 AM

이것은 Laravel 백엔드가있는 React Application을 구축하는 데있어 시리즈의 두 번째이자 마지막 부분입니다. 이 시리즈의 첫 번째 부분에서는 기본 제품 목록 응용 프로그램을 위해 Laravel을 사용하여 편안한 API를 만들었습니다. 이 튜토리얼에서는 Dev가 될 것입니다

Laravel 테스트에서 단순화 된 HTTP 응답 조롱 Laravel 테스트에서 단순화 된 HTTP 응답 조롱 Mar 12, 2025 pm 05:09 PM

Laravel은 간결한 HTTP 응답 시뮬레이션 구문을 제공하여 HTTP 상호 작용 테스트를 단순화합니다. 이 접근법은 테스트 시뮬레이션을보다 직관적으로 만들면서 코드 중복성을 크게 줄입니다. 기본 구현은 다양한 응답 유형 단축키를 제공합니다. Illuminate \ support \ Facades \ http를 사용하십시오. http :: 가짜 ([ 'google.com'=> ​​'Hello World', 'github.com'=> ​​[ 'foo'=> 'bar'], 'forge.laravel.com'=>

PHP의 컬 : REST API에서 PHP Curl Extension 사용 방법 PHP의 컬 : REST API에서 PHP Curl Extension 사용 방법 Mar 14, 2025 am 11:42 AM

PHP 클라이언트 URL (CURL) 확장자는 개발자를위한 강력한 도구이며 원격 서버 및 REST API와의 원활한 상호 작용을 가능하게합니다. PHP CURL은 존경받는 다중 프로모토콜 파일 전송 라이브러리 인 Libcurl을 활용하여 효율적인 execu를 용이하게합니다.

Codecanyon에서 12 개의 최고의 PHP 채팅 스크립트 Codecanyon에서 12 개의 최고의 PHP 채팅 스크립트 Mar 13, 2025 pm 12:08 PM

고객의 가장 긴급한 문제에 실시간 인스턴트 솔루션을 제공하고 싶습니까? 라이브 채팅을 통해 고객과 실시간 대화를 나누고 문제를 즉시 해결할 수 있습니다. 그것은 당신이 당신의 관습에 더 빠른 서비스를 제공 할 수 있도록합니다.

2025 PHP 상황 조사 발표 2025 PHP 상황 조사 발표 Mar 03, 2025 pm 04:20 PM

2025 PHP Landscape Survey는 현재 PHP 개발 동향을 조사합니다. 개발자와 비즈니스에 대한 통찰력을 제공하는 프레임 워크 사용, 배포 방법 및 과제를 탐색합니다. 이 조사는 현대 PHP Versio의 성장을 예상합니다

See all articles