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

Function OnGCAllocation

Source/Engine/Scripting/Runtime/Mono.cpp:288–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void OnGCAllocation(MonoProfiler* profiler, MonoObject* obj)
289{
290 // Get allocation info
291 auto klass = mono_object_get_class(obj);
292 //auto name_space = mono_class_get_namespace(klass);
293 //auto name = mono_class_get_name(klass);
294 auto size = mono_class_instance_size(klass);
295
296 //LOG(Info, "GC new: {0}.{1} ({2} bytes)", name_space, name, size);
297
298#if 0
299 if (ProfilerCPU::IsProfilingCurrentThread())
300 {
301 static int details = 0;
302 if (details)
303 {
304 StackWalkDataResult stackTrace;
305 stackTrace.Buffer.SetCapacity(1024);
306 mono_stack_walk(&OnStackWalk, &stackTrace);
307
308 const auto msg = String::Format(TEXT("GC new: {0}.{1} ({2} bytes). Stack Trace:\n{3}"), String(name_space), String(name), size, stackTrace.Buffer.ToStringView());
309 Platform::Log(*msg);
310 //LOG_STR(Info, msg);
311 }
312 }
313#endif
314
315#if COMPILE_WITH_PROFILER
316 // Register allocation during the current CPU event
317 auto thread = ProfilerCPU::GetCurrentThread();
318 if (thread != nullptr && thread->Buffer.GetCount() != 0)
319 {
320 auto& activeEvent = thread->Buffer.Last().Event();
321 if (activeEvent.End < ZeroTolerance)
322 {
323 activeEvent.ManagedMemoryAllocation += size;
324 }
325 }
326#endif
327}
328
329void OnGCEvent(MonoProfiler* profiler, MonoProfilerGCEvent event, uint32_t generation, mono_bool is_serial)
330{

Callers

nothing calls this directly

Calls 8

ToStringViewMethod · 0.80
EventMethod · 0.80
FormatFunction · 0.50
StringFunction · 0.50
LogFunction · 0.50
SetCapacityMethod · 0.45
GetCountMethod · 0.45
LastMethod · 0.45

Tested by

no test coverage detected