Comment resoudre ce probleme en netbeans

cs_chahde14 Messages postés 16 Date d'inscription mardi 9 décembre 2008 Statut Membre Dernière intervention 20 août 2011 - 17 août 2011 à 00:47
cs_chahde14 Messages postés 16 Date d'inscription mardi 9 décembre 2008 Statut Membre Dernière intervention 20 août 2011 - 20 août 2011 à 00:23
slt
quand je lance l'execution de mon petit programme il m'affiche cette erreur
si vous pouvez m'aider comment corriger cette erreur
merci.

8 réponses

cs_chahde14 Messages postés 16 Date d'inscription mardi 9 décembre 2008 Statut Membre Dernière intervention 20 août 2011
17 août 2011 à 00:48
dsl voila l'erreur:

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at desktopapplication2.DesktopApplication2View.(DesktopApplication2View.java:38)
at desktopapplication2.DesktopApplication2.startup(DesktopApplication2.java:19)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
0
cs_Julien39 Messages postés 6414 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 29 juillet 2020 371
17 août 2011 à 07:59
Bonjour,

java.lang.OutOfMemoryError : t n'a pas assez de mémoire pour terminer le processus. Si c'est un petit programme c'est que tu as fait une erreur. Montre nous ton code qu'on puisse t'en dire plus.
0
cs_chahde14 Messages postés 16 Date d'inscription mardi 9 décembre 2008 Statut Membre Dernière intervention 20 août 2011
17 août 2011 à 13:17
slt voila mon code


/*
* DesktopApplication2View.java
*/

package desktopapplication2;

import Jama.Matrix;
import Jama.SingularValueDecomposition;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
* The application's main frame.
*/
public class DesktopApplication2View extends FrameView {
String[] mots;
double[][] mat;
int nbmots;
public DesktopApplication2View(SingleFrameApplication app) {
super(app);

initComponents();
this.jFileChooser1.setVisible(false);
mat=new double[1000][10000];
mots=new String[10000];
nbmots=0;
// status bar initialization - message timeout, idle icon and busy animation, etc
ResourceMap resourceMap = getResourceMap();
int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
messageTimer = new Timer(messageTimeout, new ActionListener() {
public void actionPerformed(ActionEvent e) {
statusMessageLabel.setText("");
}
});
messageTimer.setRepeats(false);
int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
for (int i = 0; i < busyIcons.length; i++) {
busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
}
busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
public void actionPerformed(ActionEvent e) {
busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
}
});
idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);

// connecting action tasks to status bar via TaskMonitor
TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
String propertyName = evt.getPropertyName();
if ("started".equals(propertyName)) {
if (!busyIconTimer.isRunning()) {
statusAnimationLabel.setIcon(busyIcons[0]);
busyIconIndex = 0;
busyIconTimer.start();
}
progressBar.setVisible(true);
progressBar.setIndeterminate(true);
} else if ("done".equals(propertyName)) {
busyIconTimer.stop();
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);
progressBar.setValue(0);
} else if ("message".equals(propertyName)) {
String text = (String)(evt.getNewValue());
statusMessageLabel.setText((text == null) ? "" : text);
messageTimer.restart();
} else if ("progress".equals(propertyName)) {
int value = (Integer)(evt.getNewValue());
progressBar.setVisible(true);
progressBar.setIndeterminate(false);
progressBar.setValue(value);
}
}
});
}

@Action
public void showAboutBox() {
if (aboutBox == null) {
JFrame mainFrame = DesktopApplication2.getApplication().getMainFrame();
aboutBox = new DesktopApplication2AboutBox(mainFrame);
aboutBox.setLocationRelativeTo(mainFrame);
}
DesktopApplication2.getApplication().show(aboutBox);
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

mainPanel = new javax.swing.JPanel();
jFileChooser1 = new javax.swing.JFileChooser();
jButton1 = new javax.swing.JButton();
menuBar = new javax.swing.JMenuBar();
javax.swing.JMenu fileMenu = new javax.swing.JMenu();
jMenu1 = new javax.swing.JMenu();
jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();
jCheckBoxMenuItem3 = new javax.swing.JCheckBoxMenuItem();
jCheckBoxMenuItem4 = new javax.swing.JCheckBoxMenuItem();
javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
javax.swing.JMenu helpMenu = new javax.swing.JMenu();
javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
statusPanel = new javax.swing.JPanel();
javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
statusMessageLabel = new javax.swing.JLabel();
statusAnimationLabel = new javax.swing.JLabel();
progressBar = new javax.swing.JProgressBar();
jDialog1 = new javax.swing.JDialog();

org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopapplication2.DesktopApplication2.class).getContext().getResourceMap(DesktopApplication2View.class);
mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
mainPanel.setForeground(resourceMap.getColor("mainPanel.foreground")); // NOI18N
mainPanel.setName("mainPanel"); // NOI18N

jFileChooser1.setBackground(resourceMap.getColor("jFileChooser1.background")); // NOI18N
jFileChooser1.setMultiSelectionEnabled(true);
jFileChooser1.setName("jFileChooser1"); // NOI18N
jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jFileChooser1ActionPerformed(evt);
}
});

jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
jButton1.setName("jButton1"); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addGap(49, 49, 49)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 70, Short.MAX_VALUE)
.addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(133, 133, 133))
);
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addGap(195, 195, 195)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addContainerGap(132, Short.MAX_VALUE))
);

menuBar.setName("menuBar"); // NOI18N

fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
fileMenu.setName("fileMenu"); // NOI18N

jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
jMenu1.setName("jMenu1"); // NOI18N
jMenu1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jMenu1MouseClicked(evt);
}
});
jMenu1.addContainerListener(new java.awt.event.ContainerAdapter() {
public void componentAdded(java.awt.event.ContainerEvent evt) {
jMenu1ComponentAdded(evt);
}
});
jMenu1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1ActionPerformed(evt);
}
});

jCheckBoxMenuItem2.setText(resourceMap.getString("jCheckBoxMenuItem2.text")); // NOI18N
jCheckBoxMenuItem2.setName("jCheckBoxMenuItem2"); // NOI18N
jMenu1.add(jCheckBoxMenuItem2);

jCheckBoxMenuItem3.setText(resourceMap.getString("jCheckBoxMenuItem3.text")); // NOI18N
jCheckBoxMenuItem3.setIcon(resourceMap.getIcon("jCheckBoxMenuItem3.icon")); // NOI18N
jCheckBoxMenuItem3.setName("jCheckBoxMenuItem3"); // NOI18N
jMenu1.add(jCheckBoxMenuItem3);

jCheckBoxMenuItem4.setText(resourceMap.getString("jCheckBoxMenuItem4.text")); // NOI18N
jCheckBoxMenuItem4.setName("jCheckBoxMenuItem4"); // NOI18N
jMenu1.add(jCheckBoxMenuItem4);

fileMenu.add(jMenu1);

javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(desktopapplication2.DesktopApplication2.class).getContext().getActionMap(DesktopApplication2View.class, this);
exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
exitMenuItem.setName("exitMenuItem"); // NOI18N
fileMenu.add(exitMenuItem);

menuBar.add(fileMenu);

helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
helpMenu.setName("helpMenu"); // NOI18N

aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
aboutMenuItem.setName("aboutMenuItem"); // NOI18N
helpMenu.add(aboutMenuItem);

menuBar.add(helpMenu);

statusPanel.setName("statusPanel"); // NOI18N

statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

statusMessageLabel.setName("statusMessageLabel"); // NOI18N

statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

progressBar.setName("progressBar"); // NOI18N

javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
statusPanel.setLayout(statusPanelLayout);
statusPanelLayout.setHorizontalGroup(
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 630, Short.MAX_VALUE)
.addGroup(statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(statusMessageLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 460, Short.MAX_VALUE)
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(statusAnimationLabel)
.addContainerGap())
);
statusPanelLayout.setVerticalGroup(
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(statusPanelLayout.createSequentialGroup()
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(statusMessageLabel)
.addComponent(statusAnimationLabel)
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3))
);

jDialog1.setName("jDialog1"); // NOI18N

javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);

setComponent(mainPanel);
setMenuBar(menuBar);
setStatusBar(statusPanel);
}// </editor-fold>

private void jMenu1ComponentAdded(java.awt.event.ContainerEvent evt) {
// String montext=add.Fichier("C:\\corpus"); // TODO add your handling code here:
}

private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:
}

private void jMenu1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:

this.jFileChooser1.showOpenDialog(this.getComponent());

this.jFileChooser1.setVisible(true);
File[] fichiers=this.jFileChooser1.getSelectedFiles();
for(int h=0;h<fichiers.length;h++)
{
String strLignes=new String();
//ouvrir le fichier
try

{

Scanner scanner = new Scanner(fichiers[h]);


try
{
// On boucle sur chaque champ detecté
while (scanner.hasNextLine())
{
String line = scanner.nextLine();

strLignes=strLignes.concat(line+" ");
// traitement à faire <<<<<<<<<<<<<<<<<<<<<<<<<<<<
// par exemple:
//System.out.println(line);

}
}
finally
{
// dans tous les cas, on ferme nos flux
scanner.close();
}
}
catch (IOException ioe)
{
//e.printStackTrace();
System.out.println("Erreur --" + ioe.toString());
}

System.out.println(strLignes);
System.out.println("calcule de tf");
Vector text=new Vector();
Vector tf=new Vector();
StringTokenizer temp=new StringTokenizer(strLignes.toLowerCase()," \r\t\n. ,;:\\\'\\"()?!#&@$[]{}+-/\\\\=*'<>%",false);
while(temp.hasMoreTokens()) text.add(temp.nextToken());
for( int i=0;i<text.size();i++)
{
int t=1;
for(int j=i+1;j<text.size();j++) if(((String)text.elementAt(i)).toString().equals(((String)text.elementAt(j)).toString()) ){t++;text.removeElementAt(j);j--;}
tf.add(new Integer(t));
}
for(int j=0;j<text.size();j++)
{
String mot=(String)text.elementAt(j);
int tfmot=((Integer)(tf.elementAt(j))).intValue();

int g=-1;
for(int hh=0;hh<nbmots;hh++ ) if(mots[hh].equals(mot)) g=hh;
if(g!=-1) mat[h][g+1]=tfmot;
else
{
mots[nbmots]=mot;
mat[h][nbmots+1]=tfmot;
nbmots++;
}

}
float nc=1;
if(this.jCheckBoxMenuItem2.getState()) nc=1;
else if(this.jCheckBoxMenuItem3.getState())nc=2;
else if(this.jCheckBoxMenuItem3.getState())nc=3;

mat[h][0]=nc;

}

for(int i=0;i<fichiers.length;i++){
for (int g=0;g<nbmots;g++) System.out.print(mat[i][g]+" ");
System.out.print("\n");
}
for (int yu=0;yu<nbmots;yu++) System.out.print(mots[yu]+" ");
//////////////////////////////jama
int M 8, N 5;
Matrix B = Matrix.random(5, 3);
Matrix A = Matrix.constructWithCopy(mat);
//Matrix A = Matrix.random(M, N).times(B).times(B.transpose());
System.out.print("A = ");
A.print(9, 6);
// compute the singular vallue decomposition
System.out.println("A = U S V^T");
System.out.println();
SingularValueDecomposition s = A.svd();
System.out.print("U = ");
Matrix U = s.getU();
U.print(9, 6);
System.out.print("Sigma = ");
Matrix S = s.getS();
S.print(9, 6);
System.out.print("V = ");
Matrix V = s.getV();
V.print(9, 6);
System.out.println("rank = " + s.rank());
System.out.println("condition number = " + s.cond());
System.out.println("2-norm = " + s.norm2());

// print out singular values
System.out.print("singular values = ");
Matrix svalues = new Matrix(s.getSingularValues(), 1);
svalues.print(9, 6);

//////////////////////////////////
}

private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here


}

// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem2;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem3;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem4;
private javax.swing.JDialog jDialog1;
private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JMenu jMenu1;
private javax.swing.JPanel mainPanel;
private javax.swing.JMenuBar menuBar;
private javax.swing.JProgressBar progressBar;
private javax.swing.JLabel statusAnimationLabel;
private javax.swing.JLabel statusMessageLabel;
private javax.swing.JPanel statusPanel;
// End of variables declaration

private final Timer messageTimer;
private final Timer busyIconTimer;
private final Icon idleIcon;
private final Icon[] busyIcons = new Icon[15];
private int busyIconIndex = 0;

private JDialog aboutBox;
}
0
cs_Julien39 Messages postés 6414 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 29 juillet 2020 371
17 août 2011 à 14:54
Bonjour,

Ton code est un peu trop long pour que je puisse trouver une boucle infinie là dedans, essayes de voir si tu n'as pas un problème avec une boucle while.

Je ne sais pas si tu utilises la récursivité mais c'est souvent une cause de ce genre d'exception.

Sinon, c'est peut être une limite technique et tu n'as pas assez de ressources pour faire tourner ton programme.

Une autre remarque \r\t\n peut être remplacé par \p{Space}
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_Julien39 Messages postés 6414 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 29 juillet 2020 371
17 août 2011 à 14:56
CE genre de choses par exemple new double[1000][10000]; ça fait quand même 10000000 valeurs à enregistrer. Je pense que ca doit vite poser problème donc, ce n'est pas étonnant que tu ais ce problème.
0
cs_chahde14 Messages postés 16 Date d'inscription mardi 9 décembre 2008 Statut Membre Dernière intervention 20 août 2011
18 août 2011 à 13:21
slt
j'ai essyé de corriger l'erreur mais cette fois me donne une autre erreur :
"
Error occurred during initialization of VM
Too small initial heap for new size specified"
concernant le code j'ai besoin d'aide pour corriger cette partie si possible:


int M 8, N 5;
Matrix B = Matrix.random(5, 3);
Matrix A = Matrix.constructWithCopy(mat);
//Matrix A = Matrix.random(M, N).times(B).times(B.transpose());
System.out.print("A = ");
A.print(9, 6);
// compute the singular vallue decomposition
System.out.println("A = U S V^T");
System.out.println();
SingularValueDecomposition s = A.svd();
System.out.print("U = ");
Matrix U = s.getU();
U.print(9, 6);
System.out.print("Sigma = ");
Matrix S = s.getS();
S.print(9, 6);
System.out.print("V = ");
Matrix V = s.getV();
V.print(9, 6);
System.out.println("rank = " + s.rank());
System.out.println("condition number = " + s.cond());
System.out.println("2-norm = " + s.norm2());

// print out singular values
System.out.print("singular values = ");
Matrix svalues = new Matrix(s.getSingularValues(), 1);
svalues.print(9, 6);

//////////////////////////////////
}
0
cs_Julien39 Messages postés 6414 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 29 juillet 2020 371
18 août 2011 à 13:24
Bonjour,

Pour ton erreur, tu as attribué un espace mémoire à la JVM trop grand par rapport à la quantité de ressources de ton système.
0
cs_chahde14 Messages postés 16 Date d'inscription mardi 9 décembre 2008 Statut Membre Dernière intervention 20 août 2011
20 août 2011 à 00:23
slt
quel est le nombre qu'il faut mettre dans le champ option de machine virtuelle
j'ai essayé avec -xms10m jusqu'a Xms80m
merci
0
Rejoignez-nous