I had this situation:
loopWhen i ran the profiler. I noticed that the major portion of CPU was going into Double object creation. That's when i realized that its the classloader overload everytime the object is being created..so this is what i did:
{
Double d = someclass.compute();
}
//init variable...This simple optimization reduced a lot of CPU overload! Also if u have situations such as:
Double d = 0.0;
loop
{
d = someclass.compute();
}
loopIf feasible...try using:
{
Obj o = new Obj();
}
Obj o = new Obj();This approach is not always feasible...especially if you intend to use the reference of the object elsewhere, my point is, to reduce object creation wherever feasible.
loop
{
//use o...
o.set(abc);
}
0 comments:
Post a Comment