Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
"OutofmemoryError" error occurs
when JVM is unable to allocate Memory for creating any
new variables while performing some task.
This could be solved in by following steps:
i) First and
foremost, check the memory settings of your application (JVM), if
there is
any scope to increase the Memory settings,
please change those, if not you may need to
tune the
application. So first please review the Memory Parameters i.e.
"-Xmx. -Xmx" values,
usually you could
find these in SetEnv bat (or .sh) file or you could also
provide these as
System (-D) parameters to JVM.
-Xmn512M -Xms1024M
ii) Tune the application by
using some Profilers such as JProfilier or Optimize it and make
sure
all Unused objects are reachable to Garbage
Collectors by
setting the NULL value to
garbage-collect
them.
iii) Use soft Or Weak references to avoid
this as shown below.
private
SoftReference<byte[]> bufferRef;
iv) Close all Database Connections and File IO streams
properly in Finally block as
shown below and avoid
connection leaks.
try{
} finally {
con.close();
}
v) Close all
IO streams which are used for performing File operations such as
filinputsteam
or filinputsteam.
FileInputStream fin = null;
try{
fin = new FileInputStream(file)
} finally {
fin.close();
}
vi) See if
you could use Object Pool instead of creating unlimited new
Objects.
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.