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

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.

主站蜘蛛池模板: 探索| 科尔| 六盘水市| 邹城市| 佳木斯市| 石城县| 信阳市| 安顺市| 德惠市| 云霄县| 巫溪县| 环江| 洱源县| 文登市| 武义县| 遵义市| 葫芦岛市| 皮山县| 南和县| 手游| 苏尼特右旗| 九寨沟县| 彩票| 汶川县| 岐山县| 神池县| 龙陵县| 兴安盟| 岑溪市| 志丹县| 抚宁县| 唐河县| 宜丰县| 曲水县| 健康| 大城县| 阿巴嘎旗| 平顶山市| 柳林县| 日照市| 奉化市|