其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
关于内存释放的讨论实验

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

以前看过DENGJIE的一篇关于FLASH中内存释放的文章所以我做了如下的实验

var newPerson:Person = new Person("Nate", 32);

var person_1:Person = new Person("Nate", 32);

var person_2:Person = new Person("Jane", 28);

trace(person_1.showInfo());

//out.print:我的名字是:Nate,我的年龄是:32

trace(person_2.showInfo());

//out.print:我的名字是:Jane,我的年龄是:28

trace(newPerson.showInfo());

//out.print:我的名字是:Nate,我的年龄是:32

var preson_0 = newPerson;

newPerson.age = 26;

newPerson.name = "rerd";

trace(newPerson.showInfo());

//out.print:我的名字是:rerd,我的年龄是:26

trace(preson_0.showInfo());

//out.print:我的名字是:rerd,我的年龄是:26

trace(preson_0.age);

//out.print:26

trace(preson_0.name);

//out.print:rerd

//***从上可以看出复制一个对象,只是将新的对象指向内存的一个地址

//

delete newPerson;

trace(newPerson.showInfo());

//out.print:undefined

trace(preson_0.showInfo());

//out.print:我的名字是:rerd,我的年龄是:26

//***虽然将第一个对象删除了,但是因为仍有对象指向该内存地址,所以内存仍然没有释放

trace(preson_0.age);

trace(preson_0.name);

所以说delete 不是一定能将内存释放出来




相关文章

相关软件