Skip to content

Commit fd93679

Browse files
Add heap_size to get_gc_stats
1 parent da497d1 commit fd93679

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/test/test_gc_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
GC_STATS_FIELDS = (
2424
"gen", "iid", "ts_start", "ts_stop", "collections", "collected",
25-
"uncollectable", "candidates", "duration")
25+
"uncollectable", "candidates", "heap_size", "duration")
2626

2727

2828
def get_interpreter_identifiers(gc_stats) -> tuple[int,...]:

Modules/_remote_debugging/gc_stats.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ read_gc_stats(struct gc_stats *stats, int64_t iid, PyObject *result,
5353
SET_FIELD(PyLong_FromSsize_t, items->collected);
5454
SET_FIELD(PyLong_FromSsize_t, items->uncollectable);
5555
SET_FIELD(PyLong_FromSsize_t, items->candidates);
56+
SET_FIELD(PyLong_FromSsize_t, items->heap_size);
5657

5758
SET_FIELD(PyFloat_FromDouble, items->duration);
5859

Modules/_remote_debugging/module.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static PyStructSequence_Field GCStatsInfo_fields[] = {
143143
{"collected", "Total number of collected objects"},
144144
{"uncollectable", "Total number of uncollectable objects"},
145145
{"candidates", "Total objects considered and traversed"},
146+
{"heap_size", "Number of live objects"},
146147
{"duration", "Total collection time, in seconds"},
147148
{NULL}
148149
};
@@ -151,7 +152,7 @@ PyStructSequence_Desc GCStatsInfo_desc = {
151152
"_remote_debugging.GCStatsInfo",
152153
"Information about a garbage collector stats sample",
153154
GCStatsInfo_fields,
154-
9
155+
10
155156
};
156157

157158
/* ============================================================================
@@ -1225,6 +1226,7 @@ Returns a list of GCStatsInfo objects with GC statistics data.
12251226
- collected: Total number of collected objects.
12261227
- uncollectable: Total number of uncollectable objects.
12271228
- candidates: Total objects considered and traversed.
1229+
- heap_size: number of live objects.
12281230
- duration: Total collection time, in seconds.
12291231
12301232
Raises:

0 commit comments

Comments
 (0)