![]() |
|
|||
File indexing completed on 2025-02-22 10:42:26
0001 // Copyright 2021 the V8 project authors. All rights reserved. 0002 // Use of this source code is governed by a BSD-style license that can be 0003 // found in the LICENSE file. 0004 0005 #ifndef INCLUDE_CPPGC_HEAP_STATISTICS_H_ 0006 #define INCLUDE_CPPGC_HEAP_STATISTICS_H_ 0007 0008 #include <cstddef> 0009 #include <cstdint> 0010 #include <string> 0011 #include <vector> 0012 0013 namespace cppgc { 0014 0015 /** 0016 * `HeapStatistics` contains memory consumption and utilization statistics for a 0017 * cppgc heap. 0018 */ 0019 struct HeapStatistics final { 0020 /** 0021 * Specifies the detail level of the heap statistics. Brief statistics contain 0022 * only the top-level allocated and used memory statistics for the entire 0023 * heap. Detailed statistics also contain a break down per space and page, as 0024 * well as freelist statistics and object type histograms. Note that used 0025 * memory reported by brief statistics and detailed statistics might differ 0026 * slightly. 0027 */ 0028 enum DetailLevel : uint8_t { 0029 kBrief, 0030 kDetailed, 0031 }; 0032 0033 /** 0034 * Object statistics for a single type. 0035 */ 0036 struct ObjectStatsEntry { 0037 /** 0038 * Number of allocated bytes. 0039 */ 0040 size_t allocated_bytes; 0041 /** 0042 * Number of allocated objects. 0043 */ 0044 size_t object_count; 0045 }; 0046 0047 /** 0048 * Page granularity statistics. For each page the statistics record the 0049 * allocated memory size and overall used memory size for the page. 0050 */ 0051 struct PageStatistics { 0052 /** Overall committed amount of memory for the page. */ 0053 size_t committed_size_bytes = 0; 0054 /** Resident amount of memory held by the page. */ 0055 size_t resident_size_bytes = 0; 0056 /** Amount of memory actually used on the page. */ 0057 size_t used_size_bytes = 0; 0058 /** Statistics for object allocated on the page. Filled only when 0059 * NameProvider::SupportsCppClassNamesAsObjectNames() is true. */ 0060 std::vector<ObjectStatsEntry> object_statistics; 0061 }; 0062 0063 /** 0064 * Statistics of the freelist (used only in non-large object spaces). For 0065 * each bucket in the freelist the statistics record the bucket size, the 0066 * number of freelist entries in the bucket, and the overall allocated memory 0067 * consumed by these freelist entries. 0068 */ 0069 struct FreeListStatistics { 0070 /** bucket sizes in the freelist. */ 0071 std::vector<size_t> bucket_size; 0072 /** number of freelist entries per bucket. */ 0073 std::vector<size_t> free_count; 0074 /** memory size consumed by freelist entries per size. */ 0075 std::vector<size_t> free_size; 0076 }; 0077 0078 /** 0079 * Space granularity statistics. For each space the statistics record the 0080 * space name, the amount of allocated memory and overall used memory for the 0081 * space. The statistics also contain statistics for each of the space's 0082 * pages, its freelist and the objects allocated on the space. 0083 */ 0084 struct SpaceStatistics { 0085 /** The space name */ 0086 std::string name; 0087 /** Overall committed amount of memory for the heap. */ 0088 size_t committed_size_bytes = 0; 0089 /** Resident amount of memory held by the heap. */ 0090 size_t resident_size_bytes = 0; 0091 /** Amount of memory actually used on the space. */ 0092 size_t used_size_bytes = 0; 0093 /** Statistics for each of the pages in the space. */ 0094 std::vector<PageStatistics> page_stats; 0095 /** Statistics for the freelist of the space. */ 0096 FreeListStatistics free_list_stats; 0097 }; 0098 0099 /** Overall committed amount of memory for the heap. */ 0100 size_t committed_size_bytes = 0; 0101 /** Resident amount of memory held by the heap. */ 0102 size_t resident_size_bytes = 0; 0103 /** Amount of memory actually used on the heap. */ 0104 size_t used_size_bytes = 0; 0105 /** Detail level of this HeapStatistics. */ 0106 DetailLevel detail_level; 0107 0108 /** Statistics for each of the spaces in the heap. Filled only when 0109 * `detail_level` is `DetailLevel::kDetailed`. */ 0110 std::vector<SpaceStatistics> space_stats; 0111 0112 /** 0113 * Vector of `cppgc::GarbageCollected` type names. 0114 */ 0115 std::vector<std::string> type_names; 0116 }; 0117 0118 } // namespace cppgc 0119 0120 #endif // INCLUDE_CPPGC_HEAP_STATISTICS_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |