CRITICAL
Rule Definition
One of the fundamental OO performance management principles is: avoid excessive object creation. This doesn't mean that you should give up the benefits of object-oriented programming by not creating any objects, but you should be wary of object creation inside tight loops when executing performance-critical code. Object creation is expensive enough that you should avoid unnecessarily creating temporary or intermediate objects in situations where performance is an issue.
Remediation
Modify the sourc code to reduce the number of Methods containing object instantiation in loops.
Violation Code Sample
class ClassTest
{
function test1()
{
for ($i=0; $i<10; $i++)
{
$bar = new Test;
$bar->do_something();
}
}
}
Related Technologies
Technical Criterion
CWE-1050 - Excessive Platform Resource Consumption within a Loop
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.