MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ReleaseObjects

Function ReleaseObjects

Source/Engine/Scripting/Scripting.cpp:117–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115#endif
116
117 void ReleaseObjects(bool gameOnly)
118 {
119 // Flush objects already enqueued objects to delete
120 ObjectsRemovalService::Flush();
121
122 // Give GC a try to cleanup old user objects and the other mess
123 MCore::GC::Collect();
124 MCore::GC::WaitForPendingFinalizers();
125
126 // Destroy objects from game assemblies (eg. not released objects that might crash if persist in memory after reload)
127 const auto flaxModule = GetBinaryModuleFlaxEngine();
128 _objectsLocker.Lock();
129 for (auto i = _objectsDictionary.Begin(); i.IsNotEnd(); ++i)
130 {
131 auto obj = i->Value;
132 if (gameOnly && obj->GetTypeHandle().Module == flaxModule)
133 continue;
134
135#if USE_OBJECTS_DISPOSE_CRASHES_DEBUGGING
136 LOG(Info, "[OnScriptingDispose] obj = 0x{0:x}, {1}", (uint64)obj.Ptr, String(obj.TypeName));
137#endif
138 obj->OnScriptingDispose();
139 }
140 _objectsLocker.Unlock();
141
142 // Release assets sourced from game assemblies
143 Array<Asset*> assets = Content::GetAssets();
144 for (auto asset : assets)
145 {
146 if (asset->GetTypeHandle().Module == flaxModule)
147 {
148 continue;
149 }
150
151 asset->DeleteObject();
152 }
153 ObjectsRemovalService::Flush();
154 }
155}
156
157Delegate<BinaryModule*> Scripting::BinaryModuleLoaded;

Callers 2

ReleaseMethod · 0.85
ReloadMethod · 0.85

Calls 10

CollectFunction · 0.85
GetAssetsFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
DeleteObjectMethod · 0.80
FlushFunction · 0.50
StringFunction · 0.50
BeginMethod · 0.45
IsNotEndMethod · 0.45
OnScriptingDisposeMethod · 0.45

Tested by

no test coverage detected