Re: help with weak references

Andrew Phillips <[email protected]> Mon, 4 Jan 2016 04:15:21 -0800 (PST)
Newsgroups gmane.comp.lang.scala
Message-ID <[email protected]>

scala>  System.gc()

scala> val x = wr.wr.get
x: Option[List[Int]] = Some(List(0, 1, 2, 3, 4))  // <<------ should have 
been None


Have you been able to observe the behaviour you're expecting with 
equivalent Java code? I'm asking because, from what I can see, the 
System.gc documentation [1] doesn't make any guarantees that weak 
references will be collected - or, at least, that they will have been 
collected when the call returns.

If you wait a while longer or add a loop to create "more garbage", does the 
behaviour change?

Regards

ap

[1] https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#gc--

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.