Hmm,
lets see
Quote:
The -XX:+DoEscapeAnalysis option directs HotSpot to look for objects that are created and referenced by a single thread within the scope of a method compilation.
dx is created withing the scope, thats "x.multiply(p.getX())"
dx is referenced within the scope, thats "r.translate(dx)"
Potentially dx could escape through "translate" but it is only accessed read only.
In this case the optimization should jump in. I missed to provide that code snipped.
If an object "escapes" and is read-only accessed, HotSpot might inline all the code in the method and eliminate the object creation.
You may check this here:
http://java.sun.com/javase/7/docs/technotes/guides/vm/performance-enhancements-7.htmlThe thing is I tried to run the example from this page, but escape analysis didn´t jump in either. I have some code snippets now, that are more clearly:
public void rotate(float angle, Vector3 axis) { Matrix3 rotationMatrix = new Matrix3(); rotationMatrix.loadAxisAngleRotation(angle, axis); rotationMatrix.transformOnlyOrientation(this);}
You may see now the "rotationMatrix" isn´t even passed as a parameter, so there is no hidden magic this time, but the problem remains. The above example produces lots of object allocations.
I would really enjoy this to work, don´t want to use static methods or hacks like that.
Here is the "defensive copy" example from the page:
class Matrix3 { private Vector3 x, y, z; private Point3 pos Vector3 getX() { //Defensive copy return new Vector3(x); }}
You see the matrix has subobjects for its axes and these are returned "safely" in order to prevent manipulation from the outside. The link states this should be optimized, but it isn´t.
I would be very grateful if anybody could check that and give me advice how to enable the feature. The VM version I need and the parameters. According to the link it should work, but it doesn´t.
Btw. I am using the -Xloggc mechanism and the netbeans memory profiler to check if EA jumps in. Please tell me if anything might be wrong with that.
my java version is:
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b91)
Java HotSpot(TM) Client VM (build 18.0-b03, mixed mode, sharing)
Thank you a lot for your attention,
Frederik