On Apr 28, 2:05 pm, Ricardo Palomares Martinez <rpm.PU...@iespana.es>
wrote:
> Hi,
>
> I'm trying to find out possible memory leaks in a program. While they
> are not exactly the cause, I've found myself in front of some code
> like this:
>
> public class NonStaticClass {
> private static final String CONSTANT1 = "glossary_version";
> private static final String CONSTANT2 = "5.1";
>
> The class is not used in a static way, and usually there is none or
> one instances of it (it is used just while saving data of the
> program). I'm thinking that those "constants", of which there are a
> lot of them, shouldn't be static, as they are wasting space most part
> of the program execution. Am I right?
You've gotten way off track if your goal is to investigate memory
leaks. the space used by statics like this will be insignificant. If
you want to make them use MORE space, then make them non-static (I'm
not suggesting you do this). Defining private constants is a perfectly
reasonably thing to do.
|