ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to avoid out of memory error in java ?

user-image
تم إضافة السؤال من قبل مستخدم محذوف‎
تاريخ النشر: 2014/01/01
Asad Rathore
من قبل Asad Rathore , Java Developer , Sky News Arabia

1. Make sure resources used for any particular operation are closed in finally block like Connection, Statement, ResultSet.

2. Limitize / reduce the scope of objects.

3. Don't initiate objects in loops unless very much necessary if inevitable then try to use same reference for all objects created in loops.

4. use java.util.Collection implementations wisely  i.e. specify inital capacity parameter of constructor wisely.

5. If large data is required to be loaded then go for pagination rather loading complete data once in memory.

6. Free native system resources like AWT frame, files, JNI etc when finished with them. Example: Frame,   Dialog, and Graphics classes require that the method dispose() be called on them when they are no longer used, to free up the system resources they reserve.

7. use week References.

المزيد من الأسئلة المماثلة