English 中文(简体)
为什么 t有决定性的脱轨者?
原标题:why doesn t java have deterministic destructors?

我不理解你为什么不改变同yn。 如果有人提到某一物体,而该物体的范围并不大,则标明该物体为GC的物体,而不加以破坏。 如果情况如此,它完全有理由加以破坏。

这是否是因为该类人本身的行为不同,而该物体是否参考了? Seems solvable - if Object has a destructor, its aprtime wrong for an instance to go out of scope if there are external reference.

Please help me understand.

最佳回答

因此,我可以理解的答案是,以这种方式执行ack物体是可行的,但需要一个计算垃圾收集器。 Java(大概为NET)避免了这条路,因为:

You can augment refcounting with a "real" GC, which naturally has to run less often because only some (often small) part of the garbage generated contains cycles. Another factor is speed - a clever, optimized GC can do much better than refcounting, in particular in the presence of threads (which make incrementing/decrementing the refcounts much more costy, due to locking)

问题回答

通常采用的通用公平市价会计核算制度不使用参照计算;因此,依赖参考计算的任何办法都不会依赖典型的国际交易日志。 但是,如果提及联合核查机制,这种执行可能要慢得多。

It s not clear to me what approach you suggest in your posting. If you want somehow detect that a reference is made to an object, most likely, even the most trivial object usages would break your detection, e.g.

{
 A a = new A();
 a.m();
}

这有两个问题:

  • Reading the local variable a already makes a reference to the object (on the evaluation stack). If "making a reference" is already considered as "not eligible as a stack object", then the approach of stack objects would be impractical
  • A method is called on the object, which, in turn, might make a reference to this inside, invisible to the caller. So even if you have a policy that somehow allows access to local variables containing stack objects, you can t really allow method calls for stack objects. As that would include the call to finalize(), having stack object would be fairly pointless.

why you can t have stack objects without changing syntax. If anyone makes a reference to an object that doesn t go out of scope, flag the object for GC and don t destruct it.

除标的为,占用了您可能需要的下一个方法电话的空间。

简单的答复是,GC isn t在每一物体的删除上运行――它定期运行――而且它为什么现在除了第7JDK之外,还在尝试资源之外作出努力。

http://blogs.oracle.com/darcy/enter/project_form_try_out_try

甚至在有GC框架的情况下,C++通过单独的概念处理RAII的问题。





相关问题
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 ...