![]() | This article is rated C-class on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||
|
It would be nice to include a description of Java's phantom and soft references here. -- Doug Bell ( talk/ contrib) 11:29, 13 January 2006 (UTC)
Also, isn't using normal pointers as weak references in C++ with garbage collection libraries different semantically than using a weak reference in Java? I don't believe there is any way to tell using a normal C++ pointer if the referent object has been collected. Without this capability, a C++ "weak reference" can't be used for resource management. I don't know if this is the same for Python weak references, but I think all of this information would make an interesting expansion to the artice. -- Doug Bell ( talk/ contrib) 11:29, 13 January 2006 (UTC)
How about adding info about how this is accomplished in C++ (i.e. boost::weak_ptr and boost::shared_ptr)? Just a suggestion. :) --
Antred11 (
talk)
16:38, 7 March 2011 (UTC)
Weak references can also mean something completely unrelated, mainly how symbols are resolved in a runtime. Weak references are those symbols in an executable which may be overridden at runtime, usually by loading an optional dynamic library. See http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html Corydon76 ( talk) 09:00, 10 December 2011 (UTC)
I suggest to change the description about boost::weak_ptr to std::weak_ptr, since C++11 is already widely used and accepted and of course it is better to mention solutions which use native structures, rather than third-party. Otstoy ( talk) 17:57, 18 November 2015 (UTC)
Currently, this article uses this Java example:
import java.lang.ref.WeakReference;
public class ReferenceTest {
public static void main(String[] args) throws InterruptedException {
WeakReference r = new WeakReference(new String("I'm here"));
WeakReference sr = new WeakReference("I'm here");
System.out.println("before gc: r=" + r.get() + ", static=" + sr.get());
System.gc();
Thread.sleep(100);
// only r.get() becomes null
System.out.println("after gc: r=" + r.get() + ", static=" + sr.get());
}
}
In my opinion, this example doesn't clarify the topic at hand, but instead raises new questions.
-- Abdull ( talk) 23:00, 10 December 2012 (UTC)
2A02:C7D:A1DA:D200:AD3D:BA14:ECF9:245B ( talk) 11:20, 24 November 2019 (UTC)
The article contained this text:
I can’t make head or tail of this. I don’t know what a “main language” might be, Java from 1996 has the same kind of strong references Lisp had in 1959, C doesn’t have references at all, I don’t know who these Wain and Nesmith guys are, I don’t know what event trees are or why they might evaporate or what that has to do with weak references. I suspect this text may have been translated from a Chinese Wikipedia article but not so well that I can figure out what it’s saying. I tried to find the Wain & Nesmith 1998 text that is alluded to, but without success.
Feel free to re-add what this text was trying to say. I’ve replaced it with an introduction to the history of weak references in Java. Kragen Javier Sitaker ( talk) 21:26, 17 February 2015 (UTC)
A description of how weak references are implemented would be useful. — Preceding unsigned comment added by 81.191.74.4 ( talk) 01:41, 24 February 2015 (UTC)
JavaScript supports associative arrays with weak references as keys, although enumerating the keys is not possible in this case. -- Zzo38 ( talk) 19:42, 31 August 2016 (UTC)
![]() | This article is rated C-class on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||
|
It would be nice to include a description of Java's phantom and soft references here. -- Doug Bell ( talk/ contrib) 11:29, 13 January 2006 (UTC)
Also, isn't using normal pointers as weak references in C++ with garbage collection libraries different semantically than using a weak reference in Java? I don't believe there is any way to tell using a normal C++ pointer if the referent object has been collected. Without this capability, a C++ "weak reference" can't be used for resource management. I don't know if this is the same for Python weak references, but I think all of this information would make an interesting expansion to the artice. -- Doug Bell ( talk/ contrib) 11:29, 13 January 2006 (UTC)
How about adding info about how this is accomplished in C++ (i.e. boost::weak_ptr and boost::shared_ptr)? Just a suggestion. :) --
Antred11 (
talk)
16:38, 7 March 2011 (UTC)
Weak references can also mean something completely unrelated, mainly how symbols are resolved in a runtime. Weak references are those symbols in an executable which may be overridden at runtime, usually by loading an optional dynamic library. See http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html Corydon76 ( talk) 09:00, 10 December 2011 (UTC)
I suggest to change the description about boost::weak_ptr to std::weak_ptr, since C++11 is already widely used and accepted and of course it is better to mention solutions which use native structures, rather than third-party. Otstoy ( talk) 17:57, 18 November 2015 (UTC)
Currently, this article uses this Java example:
import java.lang.ref.WeakReference;
public class ReferenceTest {
public static void main(String[] args) throws InterruptedException {
WeakReference r = new WeakReference(new String("I'm here"));
WeakReference sr = new WeakReference("I'm here");
System.out.println("before gc: r=" + r.get() + ", static=" + sr.get());
System.gc();
Thread.sleep(100);
// only r.get() becomes null
System.out.println("after gc: r=" + r.get() + ", static=" + sr.get());
}
}
In my opinion, this example doesn't clarify the topic at hand, but instead raises new questions.
-- Abdull ( talk) 23:00, 10 December 2012 (UTC)
2A02:C7D:A1DA:D200:AD3D:BA14:ECF9:245B ( talk) 11:20, 24 November 2019 (UTC)
The article contained this text:
I can’t make head or tail of this. I don’t know what a “main language” might be, Java from 1996 has the same kind of strong references Lisp had in 1959, C doesn’t have references at all, I don’t know who these Wain and Nesmith guys are, I don’t know what event trees are or why they might evaporate or what that has to do with weak references. I suspect this text may have been translated from a Chinese Wikipedia article but not so well that I can figure out what it’s saying. I tried to find the Wain & Nesmith 1998 text that is alluded to, but without success.
Feel free to re-add what this text was trying to say. I’ve replaced it with an introduction to the history of weak references in Java. Kragen Javier Sitaker ( talk) 21:26, 17 February 2015 (UTC)
A description of how weak references are implemented would be useful. — Preceding unsigned comment added by 81.191.74.4 ( talk) 01:41, 24 February 2015 (UTC)
JavaScript supports associative arrays with weak references as keys, although enumerating the keys is not possible in this case. -- Zzo38 ( talk) 19:42, 31 August 2016 (UTC)