Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Object Recycling #1324

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/module.zig
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,14 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
// recycling bin to fit them.
if (objs.internal.thrown_on_the_floor >= (data.len / 10)) {
var iter = dead.iterator(.{ .kind = .set });
while (iter.next()) |index| {
dead_object_loop: while (iter.next()) |index| {
// We need to check if this index is already in the recycling bin since
// if it is, it could get recycled a second time while still
// in use.
for (recycling_bin.items) |recycled_index| {
if (index == recycled_index) continue :dead_object_loop;
}

// dead bitset contains data.capacity number of entries, we only care about ones that are in data.len range.
if (index > data.len - 1) break;
try recycling_bin.append(allocator, @intCast(index));
Expand Down
Loading