释放内存问题

#1 Kenneth

//model里面的定义
public function __destruct(){
                // 一些操作
               parent::__destruct;
     }
//---------------------------------

$read_table->__destruct();
//--------------------------------
上面语句运行后,后面的语句就不运行了,

2012-12-25 10:33:37

#2 jake

首先有些错误:parent::__destruct(); 这是函数

然后,析构函数的调用方法,不是直接调用。而是

$read_table = null; 这样调用。

建议你打开debug,看看出错提示。

2012-12-25 12:29:53

#3 Kenneth

jake 发表于 2012-12-25 12:29
首先有些错误:parent::__destruct(); 这是函数

然后,析构函数的调用方法,不是直接调用。而是
对象内存释放了,但是数组和变量的释放,该怎么释放。unset();函数不太好用。

2012-12-26 13:00:02

#4 jake

unset是差不多了。 php对这块都是自动处理的。找了些资料给你:

http://cn2.php.net/manual/zh/features.gc.collecting-cycles.php
http://cn2.php.net/manual/zh/features.gc.performance-considerations.php
http://cn2.php.net/manual/zh/features.gc.refcounting-basics.php
http://cn2.php.net/manual/zh/language.oop5.decon.php
http://cn2.php.net/manual/zh/function.unset.php

2012-12-26 13:03:10

#5 Kenneth

jake 发表于 2012-12-26 13:03
unset是差不多了。 php对这块都是自动处理的。找了些资料给你:

http://cn2.php.net/manual/zh/features.g ...
问题已经解决。谢谢大家!

2013-01-04 14:50:42