IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

avec Java Discussion :

heap space sur traitement de tables de gros volumes


Sujet :

avec Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé Avatar de POKOU
    Homme Profil pro
    developpeur
    Inscrit en
    Décembre 2008
    Messages
    121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 63
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : developpeur

    Informations forums :
    Inscription : Décembre 2008
    Messages : 121
    Par défaut heap space sur traitement de tables de gros volumes
    Bonjour

    je traite sequentiellement 6 tables de gros volumes.

    après le traitement de chacune je ferme bien ResutlSet et Statement.

    je n'ai pas de boucles dans mon code car les 6 classes java sont dupliquées ( sauf les traitements des colonnes) et c'est le 5ième traitement qui plante.

    la JVM me renvoie l'erreur:
    après ru
    après as
    après si
    après ad
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    at java.util.HashMap.resize(HashMap.java:462)
    at java.util.HashMap.addEntry(HashMap.java:755)
    at java.util.HashMap.put(HashMap.java:385)
    at java.util.jar.Manifest.read(Manifest.java:232)
    at java.util.jar.Manifest.<init>(Manifest.java:52)
    at java.util.jar.JarFile.getManifestFromReference(JarFile.java:165)
    at java.util.jar.JarFile.getManifest(JarFile.java:146)
    at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:696)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:228)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at com.ibm.as400.access.ConnectionDroppedException.<init>(ConnectionDroppedException.java:63)
    at com.ibm.as400.access.AS400ThreadedServer.forceDisconnect(AS400ThreadedServer.java:211)
    at com.ibm.as400.access.AS400ImplRemote.disconnectServer(AS400ImplRemote.java:451)
    at com.ibm.as400.access.AS400JDBCConnection.close(AS400JDBCConnection.java:482)
    at transfertRNCPSDirect.ProgramDirect$1.actionPerformed(ProgramDirect.java:202)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6263)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6028)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4630)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
    at java.awt.image.Raster.createPackedRaster(Raster.java:458)
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
    at sun.awt.image.SunVolatileImage.getBackupImage(SunVolatileImage.java:225)
    at sun.awt.image.VolatileSurfaceManager.getBackupSurface(VolatileSurfaceManager.java:252)
    at sun.awt.image.VolatileSurfaceManager.initialize(VolatileSurfaceManager.java:108)
    at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:72)
    at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:82)
    at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:93)
    at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:87)
    at sun.awt.windows.WComponentPeer.createVolatileImage(WComponentPeer.java:635)
    at java.awt.Component.createVolatileImage(Component.java:3363)
    at java.awt.Component$BltBufferStrategy.createBackBuffers(Component.java:4085)
    at java.awt.Component$BltBufferStrategy.<init>(Component.java:4030)
    at java.awt.Component$BltSubRegionBufferStrategy.<init>(Component.java:4283)
    at java.awt.Component.createBufferStrategy(Component.java:3614)
    at java.awt.Window.createBufferStrategy(Window.java:3015)
    at javax.swing.BufferStrategyPaintManager$BufferInfo.createBufferStrategy(BufferStrategyPaintManager.java:846)
    at javax.swing.BufferStrategyPaintManager$BufferInfo.createBufferStrategy(BufferStrategyPaintManager.java:797)
    at javax.swing.BufferStrategyPaintManager$BufferInfo.getBufferStrategy(BufferStrategyPaintManager.java:730)
    at javax.swing.BufferStrategyPaintManager.prepare(BufferStrategyPaintManager.java:506)
    at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:264)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
    at javax.swing.JComponent.paint(JComponent.java:1015)
    at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
    at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
    at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
    at java.awt.Container.paint(Container.java:1780)
    at java.awt.Window.paint(Window.java:3375)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:796)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
    at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
    at java.awt.image.Raster.createPackedRaster(Raster.java:458)
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
    at sun.awt.image.SunVolatileImage.getBackupImage(SunVolatileImage.java:225)
    at sun.awt.image.VolatileSurfaceManager.getBackupSurface(VolatileSurfaceManager.java:252)
    at sun.awt.image.VolatileSurfaceManager.initialize(VolatileSurfaceManager.java:108)
    at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:72)
    at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:82)
    at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:93)
    at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:87)
    at sun.awt.windows.WComponentPeer.createVolatileImage(WComponentPeer.java:635)
    at java.awt.Component.createVolatileImage(Component.java:3363)
    at java.awt.Component$BltBufferStrategy.createBackBuffers(Component.java:4085)
    at java.awt.Component$BltBufferStrategy.<init>(Component.java:4030)
    at java.awt.Component$BltSubRegionBufferStrategy.<init>(Component.java:4283)
    at java.awt.Component.createBufferStrategy(Component.java:3614)
    at java.awt.Window.createBufferStrategy(Window.java:3015)
    at javax.swing.BufferStrategyPaintManager$BufferInfo.createBufferStrategy(BufferStrategyPaintManager.java:846)
    at javax.swing.BufferStrategyPaintManager$BufferInfo.createBufferStrategy(BufferStrategyPaintManager.java:797)
    at javax.swing.BufferStrategyPaintManager$BufferInfo.getBufferStrategy(BufferStrategyPaintManager.java:730)
    at javax.swing.BufferStrategyPaintManager.prepare(BufferStrategyPaintManager.java:506)
    at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:264)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
    at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
    at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    auriez vous un piste pour me sortir de la ?

  2. #2
    Expert éminent
    Avatar de adiGuba
    Homme Profil pro
    Développeur Java/Web
    Inscrit en
    Avril 2002
    Messages
    13 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java/Web
    Secteur : Transports

    Informations forums :
    Inscription : Avril 2002
    Messages : 13 938
    Billets dans le blog
    1
    Par défaut
    Salut,


    Ben tu consommes trop de mémoire. Sans code ni explication sur ce que tu cherches à faire c'est difficile de t'aider...


    a++

  3. #3
    Membre confirmé Avatar de POKOU
    Homme Profil pro
    developpeur
    Inscrit en
    Décembre 2008
    Messages
    121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 63
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : developpeur

    Informations forums :
    Inscription : Décembre 2008
    Messages : 121
    Par défaut
    c'est vrai

    je transfère des tables de db2 400 dans un MySQL grâce à un defaultDataModel.

    je ne vois pas où changer la mémoire dans Websphere.
    par exemple rajouter -Xmx 900mo quelque part ?


  4. #4
    Expert éminent
    Avatar de adiGuba
    Homme Profil pro
    Développeur Java/Web
    Inscrit en
    Avril 2002
    Messages
    13 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java/Web
    Secteur : Transports

    Informations forums :
    Inscription : Avril 2002
    Messages : 13 938
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par POKOU Voir le message
    je transfère des tables de db2 400 dans un MySQL grâce à un defaultDataModel.
    C'est quoi un "defaultDataModel" ?


    Citation Envoyé par POKOU Voir le message
    je ne vois pas où changer la mémoire dans Websphere.
    par exemple rajouter -Xmx 900mo quelque part ?
    Ce serait une mauvaise idée qui ne ferait que reporter le problème à plus tard.


    Je ne sais toujours pas à quoi ressemble ton code, mais il semblerait que tu stocke toutes les données en mémoire avant de les transférer.

    Pourquoi ne pas les transférer à la volée ? Cela limitera fortement l'utilisation mémoire...


    a++

  5. #5
    Membre confirmé Avatar de POKOU
    Homme Profil pro
    developpeur
    Inscrit en
    Décembre 2008
    Messages
    121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 63
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : developpeur

    Informations forums :
    Inscription : Décembre 2008
    Messages : 121
    Par défaut
    Aîe
    Tu as raison c'est d'un DefaultTableModel dont je voulais parler.

    et pour la logique aussi tu as raison, je peux faire plus court,
    mais je en affichant mes jTables je peux voir rapidement si je transfère bien tout.

    mon code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    package transfertTOTO;
    import java.awt.*;
    import java.awt.event.ActionEvent;
     
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.sql.Timestamp;
     
    import javax.swing.*;
    import javax.swing.table.DefaultTableModel;
     
     
    public class TransfertTOTO extends ProgramDirect{
     
    	private JPanel panoR;
    	private JScrollPane jsp, jsp2;
    	private JTable table, table2;
    	private DefaultTableModel data, data2;
    	private JTextField requete, requete2;
    	private JButton load;
    	public ResultSet resultat, resultat2;
    	public String[] ligne, ligne2;
    	public ResultSetMetaData meta, meta2;
    	public static Statement statement, statement2;
     
    	public TransfertTOTO() { 
    		try {
     
    			panoR=new JPanel();
    			panoR.setVisible(true);
    			panoR.setSize(1200,600);
    //pour centrer milieu de fenetre		
    			setLocationRelativeTo(null);
    			panoR.setLayout(new BorderLayout());
    			JPanel panel = new JPanel();
    			panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    			load = new JButton("execute");
    			panel.add(load);
     
    			requete2 = new JTextField("select * from nnn.tableOrigine", 50);
    			panel.add(requete2);
     
    			requete = new JTextField("select * from tableDestination", 50);
    			panel.add(requete);
    			panoR.add(panel, BorderLayout.NORTH);
     
    			data2 = new DefaultTableModel();
    //liaison de la jtable et du datamodel
    			table2 = new JTable(data2);
    			jsp2 = new JScrollPane(table2);
    			panoR.add(jsp2, BorderLayout.CENTER);
     
     
    			data = new DefaultTableModel();
    //liaison de la jtable et du datamodel
    			table = new JTable(data);
    			jsp = new JScrollPane(table);
    			panoR.add(jsp, BorderLayout.SOUTH);
     
    			getContentPane().add(panoR);
     
    			load.addActionListener(this);
     
     
     
    			statement2 =con2.createStatement();
     
     
    			resultat2 = statement2.executeQuery(requete2.getText());
     
    			ResultSetMetaData meta2 = resultat2.getMetaData();
     
     
    			data2.setRowCount(0);
    			data2.setColumnCount(0);
    			for (int i = 1; i <= meta2.getColumnCount(); i++) {
    				data2.addColumn(meta2.getColumnLabel(i));
    			}
     
    			ligne2 = new String[meta2.getColumnCount()];
    			while (resultat2.next())	{
    				for (int i = 1; i <= meta2.getColumnCount(); i++) {ligne2[i - 1] = resultat2.getString(i); 
    				}
    				data2.addRow(ligne2);
    			}
    			statement =con.createStatement();
     
     
    			for (int l = 0; l <= data2.getRowCount()-1; l++){
     
    				statement.executeUpdate("INSERT ...		");	}
     
     
    			resultat = statement.executeQuery(requete.getText());
     
    			meta = resultat.getMetaData();
     
    			data.setRowCount(0);
    			data.setColumnCount(0);
    			for (int i = 1; i <= meta.getColumnCount(); i++){
    				data.addColumn(meta.getColumnLabel(i));
    			}
     
    			ligne = new String[meta.getColumnCount()];
    			while (resultat.next())	{
    				for (int i = 1; i <= meta.getColumnCount(); i++){
    					ligne[i - 1] = resultat.getString(i); 
    				}
    				data.addRow(ligne);
    			}
    		}
    		catch (Exception e){
    			System.out.println(e);
    		}
    		finally {
    			try {
    				resultat.close();
    			} catch (SQLException e) {
    				// TODO Bloc catch auto-généré
    				e.printStackTrace();
    			}
    			try {
    				statement.close();
    			} catch (SQLException e) {
    				// TODO Bloc catch auto-généré
    				e.printStackTrace();
    			}
    		}
    	}	
     
    	public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub	
    	}
    }
    je me demande si c'est un problème de taille des tables ?

  6. #6
    Expert éminent
    Avatar de adiGuba
    Homme Profil pro
    Développeur Java/Web
    Inscrit en
    Avril 2002
    Messages
    13 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java/Web
    Secteur : Transports

    Informations forums :
    Inscription : Avril 2002
    Messages : 13 938
    Billets dans le blog
    1
    Par défaut
    Ben ca dépend vraiment de la taille de tes tables...

    Si tu veux afficher des milliers de lignes cela va forcément avoir un gros impact mémoire, à moins de mettre en place un système de cache ou autre pour ne pas tout charger en mémoire...



    Au passage tu mélanges création d'UI et traitements "lourds" sur la BD... ce qui risque de bloquer l'EDT et ton interface graphique
    L'utilisation d'un SwingWorker serait utile.


    a++

    PS : Et je ne comprend pas une chose : WebSphere est un serveur d'application Java EE. Tu fais du Swing avec ? Donc le code Java s'exécute coté client ?!

  7. #7
    Membre chevronné
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    342
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 342
    Par défaut
    Citation Envoyé par POKOU Voir le message
    et pour la logique aussi tu as raison, je peux faire plus court,
    mais je en affichant mes jTables je peux voir rapidement si je tranfère bien tout.
    affiche plutôt les lignes ou ta a des erreur ça évitera de chargé la mémoire

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. ALTER TABLE sur gros volume
    Par Fortius94 dans le forum Requêtes
    Réponses: 2
    Dernier message: 06/09/2013, 04h10
  2. Eviter l'erreur java Heap Space sur un algo
    Par tougi dans le forum Langage
    Réponses: 17
    Dernier message: 30/03/2011, 18h38
  3. OutOfMemoryError: Java heap space sur ResultSet
    Par SuperFoieGras dans le forum Langage
    Réponses: 14
    Dernier message: 03/09/2008, 17h38
  4. Réponses: 3
    Dernier message: 24/04/2008, 12h09
  5. Réponses: 7
    Dernier message: 28/01/2008, 10h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo