-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
document WeakRef #26745
Comments
Something like this, maybe:
|
This API leaves something to be desired, however. Now that we have more efficient union handling, we might revisit #5762 and replace Ideally, this would be done before 1.0 — would this count as a breaking change? |
Since it is explicitly tracking an allocated object, there's no performance to be gained from parameterizing it (but some predictability to be lost) |
@vtjnash, could you elaborate? If I have code that operates on a x = w.value
if x !== nothing
somefunction(x)
end then currently That is, working with |
Ref #35169 for an aspect of WeakRef that should probably be included in the documentation. |
Replying here, since #35169 is closed. This behavior that objects can be accessed after finalizers have run makes
Since now through As a practical example, consider a cache of memory mapped files (byte vectors), where some caching agent opens and maps files, and keeps weak references to these around for re-use within the application. At point of looking up a cached entry, there's no way to distinguish a finalized (i.e., unmapped) from non-finalized mapped array. How could this be implemented, without touching EditA few reference to how Java and .Net do it. Javahttps://docs.oracle.com/javase/8/docs/api/java/lang/ref/WeakReference.html
.Nethttps://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/weak-references
|
It should be noted that it appears the undesirable behaviour of #35169 is now gone at least in version 1.6, which guarantees that WeakRef's don't reach finalized objects. It would be great to have developer confirmation here as well as some official documentation. |
Although #38180 made no mention of WeakRef (only WeakKey?), this is the pr that changed the behaviour of WeakRef. |
Fixes #26745. Based on suggestion by @stevengj (#26745 (comment)).
Fixes #26745. Based on suggestion by stevengj (#26745 (comment)).
The
WeakRef
type is exported but has no docstring and no other documentation that I can find.The text was updated successfully, but these errors were encountered: