- 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.
- ASP.NET Core:Cloud-ready,Enterprise Web Application Development
- Cocos2d Cross-Platform Game Development Cookbook(Second Edition)
- 自己動(dòng)手寫Java虛擬機(jī)
- C和C++安全編碼(原書第2版)
- 算法大爆炸:面試通關(guān)步步為營(yíng)
- Practical DevOps
- Raspberry Pi 2 Server Essentials
- The Data Visualization Workshop
- PhoneGap Mobile Application Development Cookbook
- 軟件架構(gòu):Python語言實(shí)現(xiàn)
- 基于Swift語言的iOS App 商業(yè)實(shí)戰(zhàn)教程
- Drupal 8 Module Development
- 響應(yīng)式架構(gòu):消息模式Actor實(shí)現(xiàn)與Scala、Akka應(yīng)用集成
- SQL 經(jīng)典實(shí)例
- Java高并發(fā)編程詳解:深入理解并發(fā)核心庫(kù)