- Unreal Engine 4 Scripting with C++ Cookbook
- William Sherif Stephen Whittle
- 139字
- 2021-07-08 10:50:50
Managed memory – deallocating memory
UObject
s 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.
- Java高并發(fā)核心編程(卷2):多線程、鎖、JMM、JUC、高并發(fā)設(shè)計(jì)模式
- OpenCV實(shí)例精解
- JavaScript語(yǔ)言精髓與編程實(shí)踐(第3版)
- Responsive Web Design by Example
- Visual Basic程序設(shè)計(jì)習(xí)題與上機(jī)實(shí)踐
- Spring MVC+MyBatis開(kāi)發(fā)從入門(mén)到項(xiàng)目實(shí)踐(超值版)
- Raspberry Pi Robotic Blueprints
- 從零開(kāi)始學(xué)Android開(kāi)發(fā)
- Android系統(tǒng)下Java編程詳解
- Python Web自動(dòng)化測(cè)試設(shè)計(jì)與實(shí)現(xiàn)
- 基于GPU加速的計(jì)算機(jī)視覺(jué)編程:使用OpenCV和CUDA實(shí)時(shí)處理復(fù)雜圖像數(shù)據(jù)
- Mastering Apache Camel
- Python 3快速入門(mén)與實(shí)戰(zhàn)
- Mastering ArcGIS Server Development with JavaScript
- Python人工智能項(xiàng)目實(shí)戰(zhàn)