v8
14.1.146 (node 25.0.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
heap-statistics.h
Go to the documentation of this file.
1
// Copyright 2021 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#
ifndef
INCLUDE_CPPGC_HEAP_STATISTICS_H_
6
#
define
INCLUDE_CPPGC_HEAP_STATISTICS_H_
7
8
#
include
<
cstddef
>
9
#
include
<
cstdint
>
10
#
include
<
string
>
11
#
include
<
vector
>
12
13
namespace
cppgc
{
14
15
/**
16
* `HeapStatistics` contains memory consumption and utilization statistics for a
17
* cppgc heap.
18
*/
19
struct
HeapStatistics
final
{
20
/**
21
* Specifies the detail level of the heap statistics. Brief statistics contain
22
* only the top-level allocated and used memory statistics for the entire
23
* heap. Detailed statistics also contain a break down per space and page, as
24
* well as freelist statistics and object type histograms. Note that used
25
* memory reported by brief statistics and detailed statistics might differ
26
* slightly.
27
*/
28
enum
DetailLevel
:
uint8_t
{
29
kBrief
,
30
kDetailed
,
31
};
32
33
/**
34
* Object statistics for a single type.
35
*/
36
struct
ObjectStatsEntry
{
37
/**
38
* Number of allocated bytes.
39
*/
40
size_t
allocated_bytes
;
41
/**
42
* Number of allocated objects.
43
*/
44
size_t
object_count
;
45
};
46
47
/**
48
* Page granularity statistics. For each page the statistics record the
49
* allocated memory size and overall used memory size for the page.
50
*/
51
struct
PageStatistics
{
52
/** Overall committed amount of memory for the page. */
53
size_t
committed_size_bytes
= 0;
54
/** Resident amount of memory held by the page. */
55
size_t
resident_size_bytes
= 0;
56
/** Amount of memory actually used on the page. */
57
size_t
used_size_bytes
= 0;
58
/** Statistics for object allocated on the page. Filled only when
59
* NameProvider::SupportsCppClassNamesAsObjectNames() is true. */
60
std
::
vector
<
ObjectStatsEntry
>
object_statistics
;
61
};
62
63
/**
64
* Statistics of the freelist (used only in non-large object spaces). For
65
* each bucket in the freelist the statistics record the bucket size, the
66
* number of freelist entries in the bucket, and the overall allocated memory
67
* consumed by these freelist entries.
68
*/
69
struct
FreeListStatistics
{
70
/** bucket sizes in the freelist. */
71
std
::
vector
<
size_t
>
bucket_size
;
72
/** number of freelist entries per bucket. */
73
std
::
vector
<
size_t
>
free_count
;
74
/** memory size consumed by freelist entries per size. */
75
std
::
vector
<
size_t
>
free_size
;
76
};
77
78
/**
79
* Space granularity statistics. For each space the statistics record the
80
* space name, the amount of allocated memory and overall used memory for the
81
* space. The statistics also contain statistics for each of the space's
82
* pages, its freelist and the objects allocated on the space.
83
*/
84
struct
SpaceStatistics
{
85
/** The space name */
86
std::string
name
;
87
/** Overall committed amount of memory for the heap. */
88
size_t
committed_size_bytes
= 0;
89
/** Resident amount of memory held by the heap. */
90
size_t
resident_size_bytes
= 0;
91
/** Amount of memory actually used on the space. */
92
size_t
used_size_bytes
= 0;
93
/** Statistics for each of the pages in the space. */
94
std
::
vector
<
PageStatistics
>
page_stats
;
95
/** Statistics for the freelist of the space. */
96
FreeListStatistics
free_list_stats
;
97
};
98
99
/** Overall committed amount of memory for the heap. */
100
size_t
committed_size_bytes
= 0;
101
/** Resident amount of memory held by the heap. */
102
size_t
resident_size_bytes
= 0;
103
/** Amount of memory actually used on the heap. */
104
size_t
used_size_bytes
= 0;
105
/** Memory retained in the page pool, not used directly by the heap. */
106
size_t
pooled_memory_size_bytes
= 0;
107
/** Detail level of this HeapStatistics. */
108
DetailLevel
detail_level
;
109
110
/** Statistics for each of the spaces in the heap. Filled only when
111
* `detail_level` is `DetailLevel::kDetailed`. */
112
std
::
vector
<
SpaceStatistics
>
space_stats
;
113
114
/**
115
* Vector of `cppgc::GarbageCollected` type names.
116
*/
117
std
::
vector
<
std
::
string
>
type_names
;
118
};
119
120
}
// namespace cppgc
121
122
#
endif
// INCLUDE_CPPGC_HEAP_STATISTICS_H_
cppgc
Definition
allocation.h:38
cppgc::HeapStatistics::FreeListStatistics
Definition
heap-statistics.h:69
cppgc::HeapStatistics::FreeListStatistics::free_size
std::vector< size_t > free_size
Definition
heap-statistics.h:75
cppgc::HeapStatistics::FreeListStatistics::free_count
std::vector< size_t > free_count
Definition
heap-statistics.h:73
cppgc::HeapStatistics::FreeListStatistics::bucket_size
std::vector< size_t > bucket_size
Definition
heap-statistics.h:71
cppgc::HeapStatistics::ObjectStatsEntry
Definition
heap-statistics.h:36
cppgc::HeapStatistics::ObjectStatsEntry::object_count
size_t object_count
Definition
heap-statistics.h:44
cppgc::HeapStatistics::ObjectStatsEntry::allocated_bytes
size_t allocated_bytes
Definition
heap-statistics.h:40
cppgc::HeapStatistics::PageStatistics
Definition
heap-statistics.h:51
cppgc::HeapStatistics::PageStatistics::object_statistics
std::vector< ObjectStatsEntry > object_statistics
Definition
heap-statistics.h:60
cppgc::HeapStatistics::PageStatistics::resident_size_bytes
size_t resident_size_bytes
Definition
heap-statistics.h:55
cppgc::HeapStatistics::PageStatistics::used_size_bytes
size_t used_size_bytes
Definition
heap-statistics.h:57
cppgc::HeapStatistics::PageStatistics::committed_size_bytes
size_t committed_size_bytes
Definition
heap-statistics.h:53
cppgc::HeapStatistics::SpaceStatistics
Definition
heap-statistics.h:84
cppgc::HeapStatistics::SpaceStatistics::page_stats
std::vector< PageStatistics > page_stats
Definition
heap-statistics.h:94
cppgc::HeapStatistics::SpaceStatistics::resident_size_bytes
size_t resident_size_bytes
Definition
heap-statistics.h:90
cppgc::HeapStatistics::SpaceStatistics::used_size_bytes
size_t used_size_bytes
Definition
heap-statistics.h:92
cppgc::HeapStatistics::SpaceStatistics::free_list_stats
FreeListStatistics free_list_stats
Definition
heap-statistics.h:96
cppgc::HeapStatistics::SpaceStatistics::name
std::string name
Definition
heap-statistics.h:86
cppgc::HeapStatistics::SpaceStatistics::committed_size_bytes
size_t committed_size_bytes
Definition
heap-statistics.h:88
cppgc::HeapStatistics::resident_size_bytes
size_t resident_size_bytes
Definition
heap-statistics.h:102
cppgc::HeapStatistics::type_names
std::vector< std::string > type_names
Definition
heap-statistics.h:117
cppgc::HeapStatistics::used_size_bytes
size_t used_size_bytes
Definition
heap-statistics.h:104
cppgc::HeapStatistics::space_stats
std::vector< SpaceStatistics > space_stats
Definition
heap-statistics.h:112
cppgc::HeapStatistics::DetailLevel
DetailLevel
Definition
heap-statistics.h:28
cppgc::HeapStatistics::kBrief
@ kBrief
Definition
heap-statistics.h:29
cppgc::HeapStatistics::kDetailed
@ kDetailed
Definition
heap-statistics.h:30
cppgc::HeapStatistics::pooled_memory_size_bytes
size_t pooled_memory_size_bytes
Definition
heap-statistics.h:106
cppgc::HeapStatistics::committed_size_bytes
size_t committed_size_bytes
Definition
heap-statistics.h:100
cppgc::HeapStatistics::detail_level
DetailLevel detail_level
Definition
heap-statistics.h:108
include
cppgc
heap-statistics.h
Generated on Thu Oct 30 2025 09:26:59 for v8 by
1.9.8