java - Does JVM manage class code by function? Is splitting a large decision function effective on memory usage? -


problem

in server-based java solution need bigger lookup table static values (about 300 kb data increases yearly new values next year).

usually table placed in database, discussed implement in java-class java code. program class 1 member function calculates table value. no object instances or other memory needs - code.

the coded table

public class lookup {   public static float getvalue (int year, int c1, int c2, int c3) {     if (year == 2012) {        if (c1 == 1) { // 70 kbyte of code              ....             return 7.34;        }     }     if (year == 2013) { // 70 kbyte of code        if (c1 == 1) {          ....             return 8.23;     }   }  } 

my question

the table increases yearly , older years used. advantage implement function per year instead of 1 having year parameter? advantage ot implement class per year? jvm detect older years not used , free memory?

special functions per year

is better? more flexible concering memory consumption?

public class lookup {    public static float getvalue (int year, int c1, int c2, int c3) {     if (year == 2012) return lookup.getvalue2012 (c1, c2, c3);     if (year == 2013) return lookup.getvalue2012 (c1, c2, c3);   }    public static float getvalue2012 (int year, int c1, int c2, int c3) {     if (c1==1) { // 70 kbyte of code              ....             return 7.34;     }   }   public static float getvalue2013 (int year, int c1, int c2, int c3) {     if (c1==1) { // 70 kbyte of code              ....             return 8.23;     }  } } 

special classes per year

or better? more flexible concering memory usage?

public class lookup {    public static float getvalue (int year, int c1, int c2, int c3) {     if (year == 2012) return lookup2012.getvalue (c1, c2, c3);     if (year == 2013) return lookup2013.getvalue (c1, c2, c3);   }  } public class lookup2012 {    public static float getvalue (int year, int c1, int c2, int c3) {     if (c1==1) { // 70 kbyte of code              ....             return 7.34;     }   } }  public class lookup2013 {    public static float getvalue (int year, int c1, int c2, int c3) {     if (c1==1) { // 70 kbyte of code              ....             return 8.23;     }  } } 

to answer question, don't think make difference splitting static methods across classes or having them in same class. reason being, irrespective of declared static methods loaded jvm once during start class loader , remain in memory till webapp undeployed. also, memory method reclaimed once method finishes executing , local references garbage collected.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -