This works well for string.buffers, but not for userdata or
cdata with attached unmanaged memory (malloc/free, mmap/munmap).
}
case GCSfinalize:
if (gcref(g->gc.mmudata) != NULL) {
+ GCSize old = g->gc.total;
if (tvref(g->jit_base)) /* Don't call finalizers on trace. */
return LJ_MAX_MEM;
gc_finalize(L); /* Finalize one userdata object. */
+ if (old >= g->gc.total && g->gc.estimate > old - g->gc.total)
+ g->gc.estimate -= old - g->gc.total;
if (g->gc.estimate > GCFINALIZECOST)
g->gc.estimate -= GCFINALIZECOST;
return GCFINALIZECOST;