Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
MallocFrameProfiler.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "Containers/Map.h"
7#include "HAL/MallocCallstackHandler.h"
8#include "HAL/Platform.h"
9
10class FMalloc;
11class FOutputDevice;
12class UWorld;
13
14class FMallocFrameProfiler final : public FMallocCallstackHandler
15{
16public:
18
19 virtual void Init() override;
20
21 /**
22 * Handles any commands passed in on the command line
23 */
24 virtual bool Exec(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) override;
25
26 /**
27 * Called once per frame, gathers and sets all memory allocator statistics into the corresponding stats. MUST BE THREAD SAFE.
28 */
29 virtual void UpdateStats() override;
30
31 static FMalloc* OverrideIfEnabled(FMalloc*InUsedAlloc);
32
33protected:
34 virtual bool IsDisabled() override;
35
36 virtual void TrackMalloc(void* Ptr, uint32 Size, int32 CallStackIndex);
37 virtual void TrackFree(void* Ptr, uint32 OldSize, int32 CallStackIndex);
38 virtual void TrackRealloc(void* OldPtr, void* NewPtr, uint32 NewSize, uint32 OldSize, int32 CallStackIndex);
39
40protected:
42 uint32 FrameCount;
44
46 {
47 int32 CallStackIndex = 0;
48 int32 Mallocs = 0;
49 int32 Frees = 0;
50 int32 UsageCount = 0;
51 int32 UniqueFrames = 0;
52 int32 LastFrameSeen = 0;
53 };
54
57};
58
59extern FMallocFrameProfiler* GMallocFrameProfiler;
bool GMallocFrameProfilerEnabled
FMallocFrameProfiler * GMallocFrameProfiler
virtual void TrackFree(void *Ptr, uint32 OldSize, int32 CallStackIndex)
virtual bool Exec(UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar) override
TMap< void *, int32 > TrackedCurrentAllocations
virtual bool IsDisabled() override
virtual void Init() override
FMallocFrameProfiler(FMalloc *InMalloc)
virtual void TrackRealloc(void *OldPtr, void *NewPtr, uint32 NewSize, uint32 OldSize, int32 CallStackIndex)
TArray< FCallStackStats > CallStackStatsArray
static FMalloc * OverrideIfEnabled(FMalloc *InUsedAlloc)
virtual void UpdateStats() override
virtual void TrackMalloc(void *Ptr, uint32 Size, int32 CallStackIndex)