[no ci] fix

This commit is contained in:
张皓晟 2025-11-23 16:17:41 +08:00
parent 061206f13e
commit d11967293f
2 changed files with 27 additions and 15 deletions

View File

@ -41,7 +41,7 @@ static void ManagedHeap__fire_debug_callback(ManagedHeap* self, ManagedHeapSwpet
c11_sbuf__ctor(&buf);
const clock_t CLOCKS_PER_MS = CLOCKS_PER_SEC / 1000;
const char* DIVIDER = "------------------------------";
const char* DIVIDER = "------------------------------------------------------------\n";
clock_t start = out_info->start / CLOCKS_PER_MS;
clock_t mark_ms = (out_info->mark_end - out_info->start) / CLOCKS_PER_MS;
@ -58,6 +58,7 @@ static void ManagedHeap__fire_debug_callback(ManagedHeap* self, ManagedHeapSwpet
pk_sprintf(&buf, "large_freed: %d\n", out_info->large_freed);
c11_sbuf__write_cstr(&buf, DIVIDER);
if(out_info->small_freed != 0 || out_info->large_freed != 0) {
char line_buf[256];
for(int i = 0; i < out_info->types_length; i++) {
const char* type_name = py_tpname(i);
@ -73,6 +74,8 @@ static void ManagedHeap__fire_debug_callback(ManagedHeap* self, ManagedHeapSwpet
c11_sbuf__write_cstr(&buf, line_buf);
}
c11_sbuf__write_cstr(&buf, DIVIDER);
}
pk_sprintf(&buf, "auto_thres.before: %d\n", out_info->auto_thres.before);
pk_sprintf(&buf, "auto_thres.after: %d\n", out_info->auto_thres.after);
pk_sprintf(&buf, "auto_thres.upper: %d\n", out_info->auto_thres.upper);
@ -141,6 +144,11 @@ int ManagedHeap__collect(ManagedHeap* self) {
int freed = ManagedHeap__sweep(self, out_info);
if(out_info) out_info->swpet_end = clock();
if(out_info) {
out_info->auto_thres.before = self->gc_threshold;
out_info->auto_thres.after = self->gc_threshold;
}
if(self->debug_callback) {
ManagedHeap__fire_debug_callback(self, out_info);
ManagedHeapSwpetInfo__delete(out_info);

View File

@ -1,5 +1,9 @@
import gc
from pkpy import setup_gc_debug_callback
setup_gc_debug_callback(print)
gc.collect()
def create_garbage():
a = [(1,2) for i in range(10000)]
return a