I have seen an awful lot of lines of Java resembling x = null; // clear memory in my day, but I’ve never written one of my own because I was never sure it was really necessary. I’m glad to see it isn’t necessary in Go.
I can’t speak for the JVM, but the CLR will even GC this during a method if it’s not referenced again and no other references to the object exist. I’d be shocked if the JVM didn’t operate identically.
I have seen an awful lot of lines of Java resembling
x = null; // clear memoryin my day, but I’ve never written one of my own because I was never sure it was really necessary. I’m glad to see it isn’t necessary in Go.It might be a result of escape analysis that you didn’t need to do it often.
I can’t speak for the JVM, but the CLR will even GC
thisduring a method if it’s not referenced again and no other references to the object exist. I’d be shocked if the JVM didn’t operate identically.