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?
TIA

Signature
If it's true that we are here to help others,
then what exactly are the OTHERS here for?
Arne Vajhøj - 28 Apr 2007 22:52 GMT
> 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
[quoted text clipped - 9 lines]
> lot of them, shouldn't be static, as they are wasting space most part
> of the program execution. Am I right?
It is very common to use static final for constants.
If we are talking JSE and not JME then I would assume the
memory used by constants is insignificant.
Arne
david.karr - 28 Apr 2007 23:45 GMT
On Apr 28, 2:05 pm, Ricardo Palomares Martinez <rpm.PU...@iespana.es>
wrote:
> Hi,
>
[quoted text clipped - 11 lines]
> 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.