I am looking for some memory leaks in java programs.
I have a class named ABCConfiguration and ABCConfigurationInfo classes. ABCConfigurationInfo is a class which have some private static final String constants and keeping a private TreeMap object. ABCConfiguration is a config class which keeps an object of ABCConfigurationInfo class (private ABCConfigurationInfo fInfo;).
When executed the program multiple times I found (using MAT) that the the objects of ABCConfigurationInfo keeps increasing. I don’t have a fix.
That is I have changed the
private ABCConfigurationInfo fInfo
to
private static ABCConfigurationInfo fInfo.
After this, I have checked the objects of ABCConfigurationInfo after multiple times of execution. It is become stable and one object is creating. Is it a real fix? Could you please advice me.
I know that, with these much information it is hard to tell.
Thanks in advance
If you can afford having the same fInfo instance on all your ABCConfiguration objects then its a valid fix.