Memory Occupied By Static Methods

Hi,

This is probably a really simple question, but I am trying to cut down on the memory cost of my program and I was wondering about the following:

Does a static method occupy any more memory than an object-oriented method (i.e. one that has to be 'instantiated'). I am referring just to the methods and everything contained within them.

Cheers,

Crispin

[387 byte] By [crispin1a] at [2007-11-27 5:50:44]
# 1

> Hi,

>

> This is probably a really simple question, but I am

> trying to cut down on the memory cost of my program

> and I was wondering about the following:

>

> Does a static method occupy any more memory than an

> object-oriented method (i.e. one that has to be

> 'instantiated'). I am referring just to the methods

> and everything contained within them.

>

> Cheers,

> Crispin

No it doesn't take more memory. And you really should concentrate on the design of the classes as to whether or not they should be static methods or not, not based on memory concerns. If the method in question need to operate on instance state, or that there is a chance of a subclass override of the method operating on state, then it should be an instance (non-static) method.

warnerjaa at 2007-7-12 15:38:43 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks for your help Warnerja :)
crispin1a at 2007-7-12 15:38:43 > top of Java-index,Java Essentials,New To Java...
# 3

> Does a static method occupy any more memory than an

> object-oriented method (i.e. one that has to be

> 'instantiated').

An object-oriented (i.e. non-static in Java) method doesn't have to be 'instantiated'. A static and a non-static method are not different in this respect so the question is not very meaningful.

ejpa at 2007-7-12 15:38:43 > top of Java-index,Java Essentials,New To Java...