mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
41 lines
1.1 KiB
HTML
41 lines
1.1 KiB
HTML
<html>
|
|
<body>
|
|
Reports object or array allocations inside loops. While not
|
|
necessarily a problem, an object allocation inside a loop is a great place to look for memory leaks
|
|
and performance issues.
|
|
<p>
|
|
The inspection reports the following constructs:
|
|
</p>
|
|
<ul>
|
|
<li>Explicit allocations via <code>new</code> operator</li>
|
|
<li>Methods known to return new object</li>
|
|
<li>Instance-bound method references</li>
|
|
<li>Lambdas that capture variables or <code>this</code> reference</li>
|
|
</ul>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
// Explicit allocation
|
|
for (Status status : Status.values()) {
|
|
declarationsMap.put(status, new ArrayList<>());
|
|
}
|
|
|
|
// Lambda captures variable
|
|
String message = "Engine running.";
|
|
for (Engine engine : engines) {
|
|
if (!isRunning(engine)) {
|
|
logger.warn(() -> {
|
|
return String.format(message);
|
|
});
|
|
}
|
|
}
|
|
|
|
// Instance-bound method reference
|
|
for(Node node : nodes) {
|
|
descriptor = node.getDescription();
|
|
descriptor.ifPresent(dynamicTestExecutor::execute);
|
|
}
|
|
</code>
|
|
</pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |