| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> php >> PHP dui xiang xiang hu yin yong de nei cun yi chu

PHP dui xiang xiang hu yin yong de nei cun yi chu

2008-12-22 08:10:48 编辑來源:互联网 评论
 
 
 
本文为【PHP对象相互引用的内存溢出】的拼音翻译版
  shi yong jiao ben yu yan zui da de hao chu zhi yi jiu shi ke li yong qi yong you de zi dong la ji hui shou ji zhi ( shi fang nei cun )。 ni bu xu yao zai shi yong wan bian liang hou zuo ren he shi fang nei cun de chu li ,PHP hui bang ni wan cheng 。
  dang ran , wo men ke yi an zi ji de yi yuan tiao yong unset() han shu lai shi fang nei cun , dan tong chang bu xu yao zhe me zuo 。
  bu guo zai PHP li , zhi shao you yi zhong qing kuang nei cun bu hui de dao zi dong shi fang , ji bian shi shou dong tiao yong unset()。 xiang qing ke kao :http://bugs.php.net/bug.php?id=33595
  wen ti zheng zhuang
  ru guo liang ge dui xiang zhi jian cun zai zhe xiang hu yin yong de guan xi , ru “ fu dui xiang - zi dui xiang ”, dui fu dui xiang tiao yong unset() bu hui shi fang zai zi dui xiang zhong yin yong fu dui xiang de nei cun ( ji bian fu dui xiang bei la ji hui shou , ye bu xing )。
  you xie hu tu le ? wo men lai kan xia mian de zhe duan dai ma :
  <?phpclass Foo {function __construct(){$this->bar = new Bar($this);}}class Bar {function __construct($foo = null){$this->foo = $foo;}}while (true) {$foo = new Foo();unset($foo);echo number_format(memory_get_usage()) . "\n";}?> yun xing zhe duan dai ma , ni hui kan dao nei cun shi yong lv yue lai yue gao yue lai yue gao , zhi dao yong guang guang 。
  ...33,551,61633,551,97633,552,33633,552,696PHP Fatal error: Allowed memory size of 33554432 bytes exhausted(tried to allocate 16 bytes) in memleak.php on line 17 dui da bu fen PHP cheng xu yuan lai jiang zhe zhong qing kuang bu suan shi shen me wen ti 。
  ke ru guo ni zai yi ge chang qi yun xing de dai ma zhong shi yong dao le yi da dui xiang hu yin yong de dui xiang , you qi shi zai dui xiang xiang dui jiao da de qing kuang xia , nei cun hui xun su di xiao hao dai jin 。
  Userland jie jue fang an
  sui ran you xie fa wei 、 bu you ya , dan zhi qian ti dao de bugs.php.net lian jie zhong ti gong le yi ge jie jue fang an 。
  zhe ge fang an zai shi fang dui xiang qian shi yong yi ge destructor fang fa yi da dao mu de 。Destructor fang fa ke jiang suo you nei bu de fu dui xiang yin yong quan bu qing chu , ye jiu shi shuo ke yi jiang zhe bu fen ben lai hui yi chu de nei cun shi fang diao 。
  yi xia shi “ xiu fu hou ” de dai ma :
  <?phpclass Foo {function __construct(){$this->bar = new Bar($this);}function __destruct(){unset($this->bar);}}class Bar {function __construct($foo = null){$this->foo = $foo;}}while (true) {$foo = new Foo();$foo->__destruct();unset($foo);echo number_format(memory_get_usage()) . "\n";}?> zhu yi na ge xin zeng de Foo::__destruct() fang fa , yi ji zai shi fang dui xiang qian dui $foo->__destruct() de tiao yong 。 xian zai zhe duan dai ma jie jue le nei cun shi yong lv yi zhi zeng jia de wen ti , zhe me yi lai , dai ma jiu ke yi hen hao de gong zuo le 。
  PHP nei gai jie jue fang an ?
  wei shen me hui you nei cun yi chu de fa sheng ? wo dui PHP nei gai fang mian de yan jiu bing bu jing tong , dan ke yi que ding de shi ci wen ti yu yin yong ji shu you guan xi 。
  zai $bar zhong yin yong $foo de yin yong ji shu bu hui yin wei fu dui xiang $foo bei shi fang er di jian , zhe shi PHP ren wei ni reng xu yao $foo dui xiang , ye jiu bu hui shi fang zhe bu fen de nei cun …… da gai shi zhe yang 。
  zhe li que shi ke yi kan chu wo de wu zhi , dan da ti yi si shi : yi ge yin yong ji shu mei you di jian , suo yi yi xie nei cun yong yuan de bu dao shi fang 。
  zai qian mian ti dao de bugs.php.net lian jie zhong wo kan dao xiu gai la ji hui shou de guo cheng jiang hui xi sheng ji da de xing neng , yin wei wo dui yin yong ji shu le jie bu duo , suo yi wo ren wei zhe shi zhen de 。
  yu qi gai bian la ji hui shou de guo cheng , wei shen me bu yong unset() dui nei bu dui xiang zuo shi fang de gong zuo ne ?( huo zhe zai shi fang dui xiang de shi hou tiao yong __destruct()?)
  ye xu PHP nei gai kai fa zhe ke yi zai ci huo qi ta di fang , dui zhe zhong la ji hui shou chu li ji zhi zuo chu xiu gai 。
  geng xin :Martin Fjordvald zai ping lun zhong ti dao le yi ge you David Wang wei la ji hui shou suo xie de bu ding ( qi shi ta kan qi lai geng xiang “ yi zheng kuai bu ”—— fei chang ju da 。 xiang qing shen jian ci you jian jie yi de CVS dao chu xin xi 。) que shi cun zai ( yi feng you jian ), bing shou dao le PHP nei gai kai fa cheng yuan de guan zhu 。 wen ti shi zhe ge bu ding yao bu yao fang dao PHP5.3 zhong bing wei de dao tai duo zhi chi 。 wo jiao de yi ge bu cuo de zhe zhong fang an jiu shi zai unset() han shu zhong tiao yong dui xiang zhong de __destruct() fang fa ;【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
shi yong jiao ben yu yan zui da de hao chu zhi yi jiu shi ke li yong qi yong you de zi dong la ji hui shou ji zhi ( shi fang nei cun )。 ni bu xu yao zai shi yong wan bian liang hou zuo ren he shi fang nei cun de chu li ,PHP hui bang ni wan cheng 。 dang ran , wo men ke yi an zi ji de yi yuan tiao yong unset() han shu lai shi fang nei cun , dan tong chang bu xu yao zhe me zuo 。 bu guo zai PHP li , zhi shao you yi zhong qing kuang nei cun bu hui de dao zi dong shi fang , ji bian shi shou dong tiao yong unset()。 xiang qing ke kao :[url=http://bugs.php.net/bug.php?id=33595]http://bugs.php.net/bug.php?id=33595[/url]。 wen ti zheng zhuang ru guo liang ge dui xiang zhi jian cun zai zhe xiang hu yin yong de guan xi , ru “ fu dui xiang - zi dui xiang ”, dui fu dui xiang tiao yong unset() bu hui shi fang zai zi dui xiang zhong yin yong fu dui xiang de nei cun ( ji bian fu dui xiang bei la ji hui shou , ye bu xing )。 you xie hu tu le ? wo men lai kan xia mian de zhe duan dai ma : <?phpclass Foo {function __construct(){$this->bar = new Bar($this);}}class Bar {function __construct($foo = null){$this->foo = $foo;}}while (true) {$foo = new Foo();unset($foo);echo number_format(memory_get_usage()) . "\n";}?> yun xing zhe duan dai ma , ni hui kan dao nei cun shi yong lv yue lai yue gao yue lai yue gao , zhi dao yong guang guang 。 ...33,551,61633,551,97633,552,33633,552,696PHP Fatal error: Allowed memory size of 33554432 bytes exhausted(tried to allocate 16 bytes) in memleak.php on line 17 dui da bu fen PHP cheng xu yuan lai jiang zhe zhong qing kuang bu suan shi shen me wen ti 。 ke ru guo ni zai yi ge chang qi yun xing de dai ma zhong shi yong dao le yi da dui xiang hu yin yong de dui xiang , you qi shi zai dui xiang xiang dui jiao da de qing kuang xia , nei cun hui xun su di xiao hao dai jin 。 Userland jie jue fang an sui ran you xie fa wei 、 bu you ya , dan zhi qian ti dao de bugs.php.net lian jie zhong ti gong le yi ge jie jue fang an 。 zhe ge fang an zai shi fang dui xiang qian shi yong yi ge destructor fang fa yi da dao mu de 。Destructor fang fa ke jiang suo you nei bu de fu dui xiang yin yong quan bu qing chu , ye jiu shi shuo ke yi jiang zhe bu fen ben lai hui yi chu de nei cun shi fang diao 。 yi xia shi “ xiu fu hou ” de dai ma : <?phpclass Foo {function __construct(){$this->bar = new Bar($this);}function __destruct(){unset($this->bar);}}class Bar {function __construct($foo = null){$this->foo = $foo;}}while (true) {$foo = new Foo();$foo->__destruct();unset($foo);echo number_format(memory_get_usage()) . "\n";}?> zhu yi na ge xin zeng de Foo::__destruct() fang fa , yi ji zai shi fang dui xiang qian dui $foo->__destruct() de tiao yong 。 xian zai zhe duan dai ma jie jue le nei cun shi yong lv yi zhi zeng jia de wen ti , zhe me yi lai , dai ma jiu ke yi hen hao de gong zuo le 。 PHP nei gai jie jue fang an ? wei shen me hui you nei cun yi chu de fa sheng ? wo dui PHP nei gai fang mian de yan jiu bing bu jing tong , dan ke yi que ding de shi ci wen ti yu yin yong ji shu you guan xi 。 zai $bar zhong yin yong $foo de yin yong ji shu bu hui yin wei fu dui xiang $foo bei shi fang er di jian , zhe shi PHP ren wei ni reng xu yao $foo dui xiang , ye jiu bu hui shi fang zhe bu fen de nei cun …… da gai shi zhe yang 。 zhe li que shi ke yi kan chu wo de wu zhi , dan da ti yi si shi : yi ge yin yong ji shu mei you di jian , suo yi yi xie nei cun yong yuan de bu dao shi fang 。 zai qian mian ti dao de bugs.php.net lian jie zhong wo kan dao xiu gai la ji hui shou de guo cheng jiang hui xi sheng ji da de xing neng , yin wei wo dui yin yong ji shu le jie bu duo , suo yi wo ren wei zhe shi zhen de 。 yu qi gai bian la ji hui shou de guo cheng , wei shen me bu yong unset() dui nei bu dui xiang zuo shi fang de gong zuo ne ?( huo zhe zai shi fang dui xiang de shi hou tiao yong __destruct()?) ye xu PHP nei gai kai fa zhe ke yi zai ci huo qi ta di fang , dui zhe zhong la ji hui shou chu li ji zhi zuo chu xiu gai 。 geng xin :Martin Fjordvald zai ping lun zhong ti dao le yi ge you David Wang wei la ji hui shou suo xie de bu ding ( qi shi ta kan qi lai geng xiang “ yi zheng kuai bu ”—— fei chang ju da 。 xiang qing shen jian ci you jian jie yi de CVS dao chu xin xi 。) que shi cun zai ( yi feng you jian ), bing shou dao le PHP nei gai kai fa cheng yuan de guan zhu 。 wen ti shi zhe ge bu ding yao bu yao fang dao PHP5.3 zhong bing wei de dao tai duo zhi chi 。 wo jiao de yi ge bu cuo de zhe zhong fang an jiu shi zai unset() han shu zhong tiao yong dui xiang zhong de __destruct() fang fa ;
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
情人节的清纯女生(9)
情人节的清纯女生(8)
情人节的清纯女生(7)
情人节的清纯女生(6)
山东蓬莱海边组照
一探哲蚌 II
一探哲蚌 III
古长城的一角
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有