Im running Eclipse Java EE juno SR2 win32 with the Findbugs plugin.
Following codesample lets FindBugs display a finding:
catch (OutOfMemoryError e) {
tryAgain = true;
log.error("try to recover", e);
System.gc(); // not so happy about this
}
And here is the discription
Bug: [..] forces garbage collection; extremely dubious except in benchmarking code
Code explicitly invokes garbage collection. Except for specific use in benchmarking, this is very dubious.
In the past, situations where people have explicitly invoked the garbage collector in routines such as close or
finalize methods has led to huge performance black holes. Garbage collection can be expensive. Any situation that forces
hundreds or thousands of garbage collections will bring the machine to a crawl.
Confidence: High, Rank: Of Concern (16)
Pattern: DM_GC
Type: Dm, Category: PERFORMANCE (Performance)
So how can i annotate this row to not beeing checked?
I've tried (source)
@edu.umd.cs.findbugs.annotations.SuppressWarnings("DM_GC")
System.gc();
which isn't working so i moved it to the method
@edu.umd.cs.findbugs.annotations.SuppressWarnings("DM_GC")
private bla(){
which is saying : "edu cannot be resolved to a type" so i tried with:
@SuppressWarnings("DM_GC")
private bla(){
and i got a "Unsupported @SuppressWarnings("DM_GC")"
This is not a request about solving the findbugs bug, its how to disable specific bugs.
Thank you!
FYI: I'm know its not a really good idea to call gc.