English 中文(简体)
java的过时提及意味着什么?
原标题:what is meant by obsolete reference in java?

I am reading Effective Java and I came across this term, "Obsolete Reference". When is a reference obsolete reference? I am assuming that all the objects that don t fall out of scope and remain unused are obsolete references. Correct me if I am wrong.

问题回答

该书使用的过时参考资料(虽然并非广泛使用的技术性术语)是一纸空文,但永远不会使用,从而防止该书所指的物体有资格获得垃圾收集,从而造成记忆泄露。

过时的提法只是一个永远不会被忽略的提法。

http://wiki.glassfish.java.net/attach/JavaPrograming/ej.html#disc5”rel=“noreferer”>Effective Java

Holding onto obsolete references constitutes memory leaks in Java. This is also termed as unintentional object retention.

Nulling out a reference to remove obsolete references to an object is good, but one must not overdo it. The best way to eliminate an obsolete reference is to reuse the variable in which it was contained or to let it fall out of scope.

E.g 删除过时参考资料,

public Object pop() {
    if (size == 0)
        throw new EmptyStackException();
    Object result = elements[--size];
    elements[size] = null; // Eliminate obsolete reference
    return result;
}

你是正确的。 基本上来说,过时的提法并不影响方案后来的流通,应当被规定为援助垃圾收集。

For example ;

String a="some value"; . . . . . . //some processing here //once done do this a=null; //a is obsolete reference

仍在备有参考文献(可能不是故意的)的未使用物体,而这些参考文献不通过您的申请/program/code加以提及,因此这一参考文献已经过时。 由于这些未使用物体的参考量仍属其范围,因此,对这些物体和这些物体内物体而言,不可能使用GC ,因而导致记忆泄露问题。

一个简单的解释是,即使从这种方法中得出的数值,该数值仍按其指数在阵列内标明。 因此,即使方案确实以过份的参考书进行,由于在笔记中所使用的内容阵列,它仍然处于 he状态。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签