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

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.

主站蜘蛛池模板: 开封县| 额尔古纳市| 德庆县| 杭锦旗| 翼城县| 土默特左旗| 辛集市| 桃园市| 凌云县| 大丰市| 灵武市| 松滋市| 沈阳市| 广水市| 衡阳市| 九台市| 金塔县| 武鸣县| 洮南市| 大方县| 松江区| 合川市| 泰州市| 开平市| 静海县| 巴彦淖尔市| 宜阳县| 荥经县| 洪江市| 宣威市| 堆龙德庆县| 罗源县| 平南县| 赤水市| 汉阴县| 万全县| 西乌| 鹿泉市| 阳曲县| 翁牛特旗| 高邮市|