In realtà questo può riguardare l'occupazione di heap e stack.
In generale tutto ciò che è locale è sullo stack, tutto ciò che è di istanza è sullo heap (anche le variabili statiche), per quanto riguarda i metodi invece dipende molto dalla implementazione della jvm (ma sta tranquillo che è ottimizzata).
leggi qui infatti
In some of Sun's implementations of the Java virtual machine, a reference to a class instance is a pointer to a handle that is itself a pair of pointers: one to a table containing the methods of the object and a pointer to the Class object that represents the type of the object, and the other to the memory allocated from the heap for the object data.
Non mi preoccuperei di un metodo lungo, ma se vuoi proprio ottimizzare cerca di lavorare sulle variabili

Rispondi quotando