我很想知道,这两种 Java方法中的任何一种在加工时间、记忆分配和(或)垃圾收集方面是否完全不同。
SomeObject myObj = new SomeObject();
myObj.doSomething();
页: 1
new SomeObject().doSomething();
我很想知道,这两种 Java方法中的任何一种在加工时间、记忆分配和(或)垃圾收集方面是否完全不同。
SomeObject myObj = new SomeObject();
myObj.doSomething();
页: 1
new SomeObject().doSomething();
4. 审视由星号生成的:
// code 1
new SomeObject().doSomething();
// bytecode 1
0: new #2; //class SomeObject
3: dup
4: invokespecial #3; //Method SomeObject."<init>":()V
7: invokevirtual #4; //Method SomeObject.doSomething:()V
10: return
你可以清楚地看到,这有两个指示:
// code 2
SomeObject myObj = new SomeObject();
myObj.doSomething();
// bytecode 2
0: new #2; //class SomeObject
3: dup
4: invokespecial #3; //Method SomeObject."<init>":()V
7: astore_1
8: aload_1
9: invokevirtual #4; //Method SomeObject.doSomething:()V
12: return
这些指示似乎非常多余,很容易优化。 如果需要,我会由JIT编辑处理。
差异完全是2个科索沃信托公司密码,该编码可转换为1个额外的机器指示,而联合信托公司可以优化这种指示(如果你不做任何与变数无关的事情)。
页: 1
假设我的奥本不会用于任何其他东西,因为我会回避你的问题的性质,你就不应看到任何区别。 不管怎么说,如果该守则在某些 lo中执行,并且已经执行过,那么你就只能担心这种管理。 如果是这样的话, Java的黄麻和黄麻制品优化应当非常妥善地照顾你们,你们不应看到任何区别。 我希望看到这部法典写出你的第二个例子,但我只是这样。
虽然按字母顺序排列的代码可能有所不同,但我认为,这应当是一个小公司优化的更为容易的事情。 视实际情况而定,甚至可以完全优化目标设定。
两者的唯一区别是,只要不批准<条码>米奥贝·条码>的参考资料,并且某一标有<条码>的物体的一部分不会被收集。
第一个例子将略微降低效率。 举例来说,标语的参考资料将一直保留到功能结束或封装为止。 在第二个例子中,一旦要求完成,就可向停车场收集对象。 当然,这实际上可能不是收集的垃圾。
我先检查了星码的生成。 Java的提及方式可能有所不同,但在这两种情况下,我怀疑它是轻而易举的。
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 ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
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 ...
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 ...
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....
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 ...