All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
在ASP.NET,Atlas中调用Web,Service—直接在ASPX页面上暴露Web,Metho_[Asp.Net教程]
ASP.NET效率陷阱之——Attributes_.net资料_编程技术
简单有效asp.net全部程序集权限配置_[Asp.Net教程]
一个使用存储过程实现的用户登录功能(含代码)_[Asp.Net教程]
架设Windows,Server,2003的安全堡垒_[SQL,Server教程]
C#2.0基本语法一_[Asp.Net教程]
关于.NET动态代理的介绍和应用简介_[Asp.Net教程]
delphi打开已经存在的映像文件
ASP.NET,Atlas简单控件介绍之界面控件_[Asp.Net教程]
SQL,Artisan多表查询和统计_.net资料_编程技术
Reading number is top 10 pictures
Sell the barbecue as says father du breul2
采访谢楠
Is said to be a Chinese female artist fame explicit pictures before2
girl of HuNan name is LiXiang(湖南辣姐李湘的写真)
The money of more than 100 countries and regions1
The most popular girls welcome eggplant
深圳的风光
The goddess of the single reason2
So beauty, will let you spray blood9
China telecom 114 spokesman MeiYanXu1
Download software ranking
The Bermuda triangle1
The cock of the Grosvenor LTD handsome
好色的外科大夫
Sora aoi's film--cangkong_Blue.Sky
Professional killers2 data package
Tram sex maniac 2 (H) rar bag10
Visual C++界面编程技术
Rio big adventure
Be there or be square
Prostitutes diary
delv published in(发表于) 2014/1/6 8:46:54 Edit(编辑)
.net回收机制的使用_[Asp.Net教程]

.net回收机制的使用_[Asp.Net教程]

.net回收机制的使用_[Asp.Net教程]

一个被终止的对象常驻内存重而不被使用的话,会占用很多系统资源,于是.net的垃圾回收器就会将它放在中止化队列中,一旦时机成熟,该对象就会被唤醒,并调用他的finalize方法,来彻底的终结他,但是利用这一机制,就可以将耗费资源的巨型类放入到一个对象池中,在程序的整个生存期内重复的使用他(结束的标志是clr认为在进程中不存在任何该应用程序的根)。我们称这些巨型类为Expensive对象,下面来讨论一下管理Expensive对象的对象池的结构。

Class Expensive{


Static Stack pool = new Stack();


Public static Expensive GetObjectFromPool(){


Retun (Expensive) pool.Pop();


}


Public static void ShutdownThePool(){


Pool = null;


}


Public Expensive(){


//先构造对象


Pool.push(this);


}


Finalize (){


If(pool!=null){


GC.RegisterForFinally(this;)//先把他叫醒挨宰


Pool.push(this);//将“清醒的”对象加入到对象池中,让他起死回生


}


}


}


Class app{


Static void main(){


New expensive();


……


Expensive e = Expensiv. GetObjectFromPool();


//下面就可以使用e了


Expensive.shutdownThepool();//关闭应用程序前,先关闭对象池,否则会在内存中留下“孔洞”,因为Finalize已经被重写了


}


}


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.