Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to avoid out of memory error in java ?

user-image
Question ajoutée par Utilisateur supprimé
Date de publication: 2014/01/01
Asad Rathore
par 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.

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?