S
Sal
Hi All!
I've some problems with a java program and memory leaks.
I Export the classes in a jar file (with eclipse) and i run it with:
java -jar app.jar
If i see the memory occupation of the program (CTRL+ALT+CANC
java.exe application) i can see that the memory start from 14.600 KB
and then grows up...
Why it appends?
Best Regards
Sal
<MAIN CLASS>
package inter;
public class Principale {
public static void main(String[] args) {
try {
Interfaccia2 app = new Interfaccia2();
} catch (NullPointerException e) {}
}
}
</MAIN CLASS>
<INTERFACE CLASS>
package inter;
import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class Interfaccia2 extends JFrame
{
JFrame f;
JLabel timeField;
int day = 0;
int mese = 0;
int anno = 0;
int h = 0;
int m = 0;
int s = 0;
Font fontlabel = new Font( "Verdana",Font.PLAIN,14);
Dimension screenSize =Toolkit.getDefaultToolkit().getScreenSize();
public Interfaccia2()
{
timeField = new JLabel("");
javax.swing.Timer t = new javax.swing.Timer(1000,
new ActionListener() {
public void actionPerformed(ActionEvent e) {
Calendar now = Calendar.getInstance();
day = now.get(Calendar.DAY_OF_MONTH);
mese = now.get(Calendar.MONTH)+1;
anno = now.get(Calendar.YEAR);
h = now.get(Calendar.HOUR_OF_DAY);
m = now.get(Calendar.MINUTE);
s = now.get(Calendar.SECOND);
timeField.setText("Data: "+ day + "-" + mese + "-" + anno + "
Ore: " + h + ":" + m + ":" + s);
}
});
t.start(); // Start the timer
timeField.setFont(fontlabel);
JPanel Panel_principale = new JPanel();
Panel_principale.setPreferredSize (new Dimension (screenSize.width-10,
screenSize.height-65));
Panel_principale.add (timeField);
f = new JFrame ("TK Data");
f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
f.getContentPane().add (Panel_principale);
f.pack();
f.setVisible (true);
f.repaint();
}
}
</INTERFACE CLASS>
I've some problems with a java program and memory leaks.
I Export the classes in a jar file (with eclipse) and i run it with:
java -jar app.jar
If i see the memory occupation of the program (CTRL+ALT+CANC
java.exe application) i can see that the memory start from 14.600 KB
and then grows up...
Why it appends?
Best Regards
Sal
<MAIN CLASS>
package inter;
public class Principale {
public static void main(String[] args) {
try {
Interfaccia2 app = new Interfaccia2();
} catch (NullPointerException e) {}
}
}
</MAIN CLASS>
<INTERFACE CLASS>
package inter;
import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class Interfaccia2 extends JFrame
{
JFrame f;
JLabel timeField;
int day = 0;
int mese = 0;
int anno = 0;
int h = 0;
int m = 0;
int s = 0;
Font fontlabel = new Font( "Verdana",Font.PLAIN,14);
Dimension screenSize =Toolkit.getDefaultToolkit().getScreenSize();
public Interfaccia2()
{
timeField = new JLabel("");
javax.swing.Timer t = new javax.swing.Timer(1000,
new ActionListener() {
public void actionPerformed(ActionEvent e) {
Calendar now = Calendar.getInstance();
day = now.get(Calendar.DAY_OF_MONTH);
mese = now.get(Calendar.MONTH)+1;
anno = now.get(Calendar.YEAR);
h = now.get(Calendar.HOUR_OF_DAY);
m = now.get(Calendar.MINUTE);
s = now.get(Calendar.SECOND);
timeField.setText("Data: "+ day + "-" + mese + "-" + anno + "
Ore: " + h + ":" + m + ":" + s);
}
});
t.start(); // Start the timer
timeField.setFont(fontlabel);
JPanel Panel_principale = new JPanel();
Panel_principale.setPreferredSize (new Dimension (screenSize.width-10,
screenSize.height-65));
Panel_principale.add (timeField);
f = new JFrame ("TK Data");
f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
f.getContentPane().add (Panel_principale);
f.pack();
f.setVisible (true);
f.repaint();
}
}
</INTERFACE CLASS>