Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
MallocDoubleFreeFinder.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Map.h"
6#include "HAL/MallocCallstackHandler.h"
7#include "HAL/Platform.h"
8
9class FMalloc;
10class FOutputDevice;
11class UWorld;
12
13class FMallocDoubleFreeFinder final : public FMallocCallstackHandler
14{
15public:
17
18 /**
19 * Handles any commands passed in on the command line
20 */
21 virtual bool Exec(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) override;
22
23 /**
24 * If you get an allocation/memory error outside of the allocator you can call this directly
25 * It will dump a callstack of the last allocator free most likely to have caused the problem to the log, if you have symbols loaded
26 * Might be useful to pass an access violation ptr to this!
27 */
28 void TrackSpecial(void* Ptr);
29
30 virtual void Init();
31
32 static FMalloc* OverrideIfEnabled(FMalloc*InUsedAlloc);
33
34protected:
35 virtual void TrackMalloc(void* Ptr, uint32 Size, int32 CallStackIndex);
36 virtual void TrackFree(void* Ptr, uint32 OldSize, int32 CallStackIndex);
37
39 {
40 SIZE_T Size;
43 Size(0),
45 {
46 };
47 TrackedAllocationData(SIZE_T InRequestedSize, int32 InCallStackIndex)
48 {
49 Size = InRequestedSize;
50 CallStackIndex = InCallStackIndex;
51 };
53 {
54 Size = 0;
55 CallStackIndex = -1;
56 };
57 };
58 TMap<const void* const, TrackedAllocationData> TrackedCurrentAllocations; // Pointer as a key to a call stack for all the current allocations we known about
59 TMap<const void* const, TrackedAllocationData> TrackedFreeAllocations; // Pointer as a key to a call stack for all allocations that have been freed
60};
61
62extern FMallocDoubleFreeFinder* GMallocDoubleFreeFinder;
bool GMallocDoubleFreeFinderEnabled
FMallocDoubleFreeFinder * GMallocDoubleFreeFinder
virtual void TrackFree(void *Ptr, uint32 OldSize, int32 CallStackIndex)
virtual bool Exec(UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar) override
virtual void TrackMalloc(void *Ptr, uint32 Size, int32 CallStackIndex)
TMap< const void *const, TrackedAllocationData > TrackedCurrentAllocations
void TrackSpecial(void *Ptr)
TMap< const void *const, TrackedAllocationData > TrackedFreeAllocations
static FMalloc * OverrideIfEnabled(FMalloc *InUsedAlloc)
FMallocDoubleFreeFinder(FMalloc *InMalloc)
TrackedAllocationData(SIZE_T InRequestedSize, int32 InCallStackIndex)