Possible Duplicate:
does these code has memory leakage??
static private ArrayList seriesColors = new ArrayList();
public Audiogram(int widthParm, int heightParm)
throws Exception
{
super(widthParm, heightParm);
seriesColors.add(new Color( 0, 0, 255));
// Set the default settings to an industrial audiogram
setType(INDUSTRIAL_AUDIOGRAM);
}
This piece of code causes memory leakage. What should be the change.
- Should i change the static variable into non static.
Generates audiogram graphs.
This class is mainly used to generate
the standard audiogram XO graph.The audiogram graph is normally
displayed with the highest value at
the bottom (i.e. -10 on top to 110 on
the bottom) so that the line goes down
as an employee’s hearing gets worse.
Assuming that your statement is accurate, and assuming that you posted the entire constructor, the
seriesColorsattribute (static or not) serves no useful purpose whatsoever.If this is the case, the then fix for the memory leak is to simply remove the
seriesColorsdeclaration from your code, as follows:However, I suspect that this is not the whole story …
EDIT
Comment out those two lines as indicated. If the code compiles with those two lines commented out, then they are definitely redundant.
However, it strikes me that your knowledge of Java must be close to zero. If this is the case, you should NOT be trying to clean up memory leaks and the like in other peoples’ code. Learn some Java first.