官术网_书友最值得收藏!

Managed memory – deallocating memory

UObjects are reference-counted and garbage-collected when there are no more references to the UObject instance. Memory allocated on a UObject class derivative using ConstructObject<> or NewObject< > can also be deallocated manually (before the reference count drops to 0) by calling the UObject::ConditionalBeginDestroy() member function.

Getting ready

You'd only do this if you were sure you no longer wanted UObject or the UObject class derivative instance in memory. Use the ConditionalBeginDestroy() function to release memory.

How to do it...

The following code demonstrates the deallocation of a UObject class:

UObject *o = NewObject< UObject >( ... );
o->ConditionalBeginDestroy();

How it works…

The command ConditionalBeginDestroy() begins the deallocation process, calling the BeginDestroy() and FinishDestroy() overrideable functions.

There's more…

Be careful not to call UObject::ConditionalBeginDestroy() on any object still being referenced in memory by other objects' pointers.

主站蜘蛛池模板: 河东区| 新郑市| 四会市| 阿城市| 贵港市| 峨眉山市| 兴安盟| 拜泉县| 昆山市| 呼伦贝尔市| 吉首市| 麻栗坡县| 金昌市| 梧州市| 叙永县| 兴业县| 汶上县| 合阳县| 界首市| 含山县| 普兰县| 济宁市| 太湖县| 当雄县| 绥芬河市| 保德县| 公安县| 岳普湖县| 景东| 萍乡市| 合山市| 墨竹工卡县| 涟源市| 安西县| 鄂尔多斯市| 施甸县| 读书| 鄂托克前旗| 平潭县| 桐乡市| 巩义市|