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

Mention pitfall in ObjectTracerContext::with_tracer doc comment #1259

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 10 additions & 4 deletions src/vm/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,16 @@ pub trait ObjectTracerContext<VM: VMBinding>: Clone + Send + 'static {

/// Create a temporary `ObjectTracer` and provide access in the scope of `func`.
///
/// When the `ObjectTracer::trace_object` is called, if the traced object is first visited
/// in this transitive closure, it will be enqueued. After `func` returns, the implememtation
/// will create work packets to continue computing the transitive closure from the newly
/// enqueued objects.
/// A typical use-case of this method is to call `ObjectTracer::trace_object` in a loop for
/// finalization candidates to create `ProcessEdgesWork` packets.
//// **Note**: Do not use this API in such a way that only one object is enqueued at a time.
/// This can result in creating a work packet for a single object, exhausting (physical) memory
/// if there are enough finalization candidates.
Comment on lines +64 to +68
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the description is too specific to the bug you fixed recently. It's not specific to finalization (it's also applicable to SoftReference), and it is better to provide an example of the right way to use it, and then describe the consequence of flipping the order of the loop and the closure. You can leave this to me. I plan to write a dedicated porting guide section for weak references and finalizers, and update this doc comment at the same time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Thank you.

///
/// When the `ObjectTracer::trace_object` is called, if the traced object is visited in this
/// transitive closure for the first time, it will be enqueued. After `func` returns, the
/// implementation will create work packets to continue computing the transitive closure from
/// the newly enqueued objects.
///
/// API functions that provide `QueuingTracerFactory` should document
/// 1. on which fields the user is supposed to call `ObjectTracer::trace_object`, and
Expand Down
Loading