forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryTracking.cpp
More file actions
132 lines (105 loc) · 4.2 KB
/
Copy pathMemoryTracking.cpp
File metadata and controls
132 lines (105 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "CommonMemoryPch.h"
// These are empty stubs here but DLL can supply an .OBJ with an implementation
#ifndef ETW_MEMORY_TRACKING
void ArenaMemoryTracking::Activate()
{
// Called to activate arena memory tracking
}
// ArenaMemoryTracking stubs
void ArenaMemoryTracking::ArenaCreated(Allocator *arena, __in LPCWSTR name)
{
// Called when arena is created.
}
void ArenaMemoryTracking::ArenaDestroyed(Allocator *arena)
{
// Called when arena is destroyed
}
void ArenaMemoryTracking::ReportAllocation(Allocator *arena, void *address, size_t size)
{
// Called when size bytes at address are allocated
}
void ArenaMemoryTracking::ReportReallocation(Allocator *arena, void *address, size_t existingSize, size_t newSize)
{
// Called when a reallocation where newSize < exsitingSize.
// This will only be called if newSize < existingSize.
// This is to inform a tracking that a realloc is taking place and ReportFree() will be called on address + newSize soon
// and the ReportFree for address will report newSize instead of existing size
}
void ArenaMemoryTracking::ReportFree(Allocator *arena, void *address, size_t size)
{
// Called when the when size bytes at address are freed. address was either reported by ReportAllocation() or as a
// result of a buffer being split reported by ReportReallocation().
// IMPORTANT: ReportFree() will always be called after ReportReallocation() to report the newly free memory of address + newSize.
}
void ArenaMemoryTracking::ReportFreeAll(Allocator *arena)
{
// Called when all the arena memory currently allocated is bulk freed.
}
void RecyclerMemoryTracking::Activate()
{
// Called to active recycler memory tracking
}
// RecyclerMemoryTracking stubs
bool RecyclerMemoryTracking::IsActive()
{
// Should return when tracking is active. This is used to force ReportFree() calls. Without this ReportFree() is only called on
// finalizable memory which is only part of the memory allocated in the recycler.
return false;
}
void RecyclerMemoryTracking::ReportRecyclerCreate(Recycler * recycler)
{
// Called when a recycler is created.
}
void RecyclerMemoryTracking::ReportRecyclerDestroy(Recycler * recycler)
{
// Called when a recycler is freed.
}
void RecyclerMemoryTracking::ReportAllocation(Recycler * recycler, __in void *address, size_t size)
{
// Called when size bytes at address are allocated from the recycler.
}
void RecyclerMemoryTracking::ReportFree(Recycler * recycler, __in void *address, size_t size)
{
// Called when size bytes at address are freed.
}
void RecyclerMemoryTracking::ReportUnallocated(Recycler * recycler, __in void* address, __in void *endAddress, size_t sizeCat)
{
// Even though the memory is not really allocated between address and endAddress,
// the recycler initially treats it as allocated and a ReportFree() will be called on it even
// though ReportAllocation() is never called. This can be treated as equivalent of the parent
// requesting the following be performed:
//
// while (address + sizeCat <= endAddress)
// {
// ReportFree(address, sizeCat);
// address += sizeCat;
// }
//
// if address where a (char *)
}
#endif
// PageTracking stubs
void PageTracking::Activate()
{
// Called to activate page allocator tracking
}
void PageTracking::PageAllocatorCreated(PageAllocator *pageAllocator)
{
// Called when a page allocator is created.
}
void PageTracking::PageAllocatorDestroyed(PageAllocator *pageAllocator)
{
// Called when a page allocator is destroyed.
}
void PageTracking::ReportAllocation(PageAllocator *pageAllocator, __in void *address, size_t size)
{
// Called when size bytes are allocated at address.
}
void PageTracking::ReportFree(PageAllocator *pageAllocator, __in void *address, size_t size)
{
// Called when size bytes are freed at address.
}