Skip to content

Commit 8ca05c9

Browse files
author
Christopher Doris
committed
document GCHook
1 parent 1c516d6 commit 8ca05c9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/GC/GC.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ function enqueue_all(ptrs)
9696
nothing
9797
end
9898

99+
"""
100+
GCHook()
101+
102+
An immortal object which frees any pending Python objects when Julia's GC runs.
103+
104+
This works by creating it but not holding any strong reference to it, so it is eligible
105+
to be finalized by Julia's GC. The finalizer empties the PythonCall GC queue if
106+
possible. The finalizer also re-attaches itself, so the object does not actually get
107+
collected and so the finalizer will run again at next GC.
108+
"""
99109
mutable struct GCHook
100110
function GCHook()
101111
finalizer(_gchook_finalizer, new())

0 commit comments

Comments
 (0)