The project that I am working on connects every end user to the database. We are using OracleOCIConnectionPooling for the logical connection. The issue here is for the error handling we are storing the error messages in the database. My question is " Is is good to load all the values at the application startup " so that it doesnt have to go the database each time when i want to retreive the error messages.
My team is opposing that, becuase they are saying that it will occupy the JVM memory and it slows down the application.
1. is that true?
2. when i deploy the application in a container where will be the JVM resides?
3.what is the difference between Server memory and JVM.
4.When I deploy the application in a container does all the class files will be in JVM? or it loads the class file whenever it needs.
5. If I create a HashMap and put all the error messages in the the HasMap , does it store it in the JVM? if its not JVM where does it stores.
For example in struts we have
String message = messageresource.getMessage(key);
and it stores key and the vlaue in the HashMap. Does that mean it stores in the JVM?
This sounds like a case of premature optimization. If the error messages don't change, they are good candidates for caching. Unless there are hundreds of them, they are unlikely to use up any significant amount of memory (presuming you have a server application.)
As to your questions:
1) Yes. Storing anything uses memory. Retrieving from the database uses CPU and I/O. These tend to be the bottlenecks in an app. If you have a very large number of error messages, you could cache them on first use rather than all at once.
2) The JVM is on the server.
3) It depends how the terms are used. Essentially you care about JVM memory.
4) Class files are loaded upon first use. Class files almost never cause a memory issue. Especially on a server.
5) Yes, it stores them in the JVM.
And yes, Struts stores data in the JVM.
I think your best question is to find out how big this data actually is. From the questions, it sounds like worrying about a non-issue though.
I really appreciate your help. Please calrify me for the following.
1. Storing the datas in the JVM is not a problem but it depends on how big the data is? If it is very Huge than storing it in the database is better option?
2. If the data is not big then store it in the HashMap that is in JVM?