5.0.2 still MEMORY LEAKS with Java on multiple tabs/windows

same problem with last update.
Memory Leaks (upto 2.5 GB) when Java applets load
in multiple windows/tab.
Someone also have this problem?
My other post prior of last update:
http://discussions.apple.com/message.jspa?messageID=12204453#12204453
Message was edited by: fascox

If you want to report this issue to Apple's engineering, send a bug report or an enhancement request via its Bug Reporter system. To do this, join the Mac Developer Program—it's free and available for all Mac users and gets you a look at some development software. Since you already have an Apple username/ID, use that. Once a member, go to Apple BugReporter and file your bug report or enhancement request. The nice thing with this procedure is that you get a response and a follow-up number; thus, starting a dialog with engineering.

Similar Messages

  • How to root out memory leak with  Java JNI & Native BDB 11g ?

    We are testing a web application using the 32-bit compiled native 11g version of BDB (with replication) under 32-bit IBM 1.5 JVM via JNI under 64-bit RedHat Linux. We are experiencing what appears to be a memory leak without a commensurate increase in Java heap size. Basically the process size continues to grow until the max 32-process size is reached (4Gb) and eventually stops running (no core). Java heap is set to 2Gb min/max. GCs are nominal, so the leak appears to be native and outside Java bytecode.
    We need to determine whether there is a memory leak in BDB, or the IBM JVM or simply a mis-use of BDB in the Java code. What tools/instrumentation/db statistic should be used to help get to root cause? Do you recommend using System Tap (with some particular text command script)? What DB stats should we capture to get to the bottom of this memory leak? What troubleshooting steps can you recommend?
    Thanks ahead of time.
    JE.
    Edited by: 787930 on Aug 12, 2010 5:42 PM

    That's troublesome... DB itself doesn't have stats that track VM in any useful way. I am not familiar with SystemTap but a quick look at it seems to imply that it's better for kernel monitoring than user space. It's pretty hard to get DB to leak significant amounts of memory. The reason is that it mostly uses shared memory carved from the environment. Also if you are neglecting to close or delete some object DB generally complains about it somewhere.
    I don't see how pmap would help if it's a heap leak but maybe I'm missing something.
    One way to rule DB out is to replace its internal memory allocation functions with your own that are instrumented to track how much VM has been allocated (and freed). This is very easy to do using the interfaces:
    db_env_set_func_malloc()
    db_env_set_func_free()
    These are global to your process and your functions will be used where DB would otherwise call malloc() and free(). How you get usage information out of the system is an exercise left to the reader :-) If it turns out DB is the culprit then there is more thinking to do to isolate the problem.
    Other ideas that can provide information if not actual smoking guns:
    -- accelerate reproduction of the problem by allocating nearly all of the VM to the JVM and the DB cache (or otherwise limit the allowable VM in your process)
    -- change the VM allocated to the JVM in various ways
    Regards,
    George

  • Still memory leaks with 10.8.4

    I hoped 10.8.4 could solve the issue..
    Unfortunately I still have memory leaks, pages out and inactive memory full for a lot of programs running. First of all FCX importing and transcoding full the inactive memory, and OSX slows down, swapping to the SSD. The same problem with all (4 in total) macs mounting ML.
    Has anyone solved the problem please?
    Thanks in advance.
    Attilio

    Attilio, although I'm not a Final Cut user, I suspect that your problem is, as Kappy first said - insufficient RAM.
    See: http://forums.macrumors.com/showthread.php?t=1332888 for instance.
    It's a RAM hog. With the Retina, you're stuck with the RAM you've got now, unfortunately. With any other hardware, I'd consider boosting the RAM as much as you can. I don't run FCX or any video editing software (I build web sites - so I use Dreamweaver, Photoshop, Lightroom etc.) and I boosted the RAM in my Mac Pro to 18GB quite a while ago because I was seeing a lot of pageouts and slowdowns with 10GB. I do tend to have a ton of windows and apps open at once.
    See also: https://discussions.apple.com/thread/4759586?start=0&tstart=0 - Kappy's very good explanation of memory usage and various links to check.
    Whether it appeared to run better in SL or not, I can't really say - unless you ran two identical Macs, side by side doing exactly the same things in FCX with the two operating systems installed, I don't know how one could accurately assess that.

  • Memory leak with UI automation

    Hi, 
    I noticed there is memory leak with UI automation in my window 8.1.
    I noticed there is solution for window 8
    http://support.microsoft.com/kb/2885482
    Is there any solution for window 8.1?
    I really appreciate for any help.

    Hi,
    I'm sorry for didn't hear anything about this issue. I'll try to connect the writer of this KB, hope we can find some suggestion. If there is any progress about this problem, I would come back.
    Roger Lu
    TechNet Community Support

  • Memory leak with 1.6.0_07 in applet using Swing

    Java Plug-in 1.6.0_07
    Using JRE version 1.6.0_07 Java HotSpot(TM) Client VM
    Windows XP - SP2
    I have a commercial application that has developed a memory leak with the introduction of the latest plugin. The applets chew up memory and eventually freeze. They did not before. Using jvisualm I see a build up of native arrays, primarily int[][] and char[]. I'm still investigating. Anyone have a similar experience?
    The Applet uses a swing interface, uses buffered images and swing timers, and regularly performs http connections to the server which result in actions via the SwingUtil.invokeLater() method.

    I am Using Internet Explorer Browser Version 6.0.Huge security hole.
    Its not throwing Error / Exception Wrap a try/catch at the highest level possible.
    Catch 'Throwable'. And log/display it somewhere.

  • Memory Leak with JPopupMenu

    It seems there is a memory leak with JPopupMenu. The following program demonstrates this leak. If you run the program, click on show form, and then close the form, the used memory will be GCd appropriately. If you click on show form, then right click on the table to show the popup (even if you dont do anything else with the popup) then close the form, it never GCs the form. I've tried all kinds of crazy things, but I cant seem to find what is keeping the memory from being GCd.
    Peter
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import java.beans.PropertyChangeListener;
    import java.text.DecimalFormat;
    import java.util.Timer;
    import java.util.TimerTask;
    import java.util.Vector;
    import javax.swing.AbstractAction;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JPopupMenu;
    import javax.swing.JRadioButtonMenuItem;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTable;
    import javax.swing.SwingUtilities;
    import javax.swing.table.AbstractTableModel;
    @SuppressWarnings("serial")
    public class TriState extends JPanel {
         private static final long               K               = 1024;
         private static final long               M               = K * K;
         private static final long               G               = M * K;
         private static final long               T               = G * K;
         protected static int ctr = 1;
         private JButton                              btnShow          = new JButton("Show Form");
         private JLabel                              lblMem          = new JLabel();
         private static final DecimalFormat     df               = new DecimalFormat("#,##0.#");
         protected Timer                              updateTimer     = new Timer();
         public TriState() {
              this.setLayout(new GridLayout());
              add(btnShow);
              add(lblMem);
              updateTimer.scheduleAtFixedRate(new UpdateTimerTask(), 1000, 1000);
              btnShow.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        FrmReferrals fr = new FrmReferrals();
                        fr.setVisible(true);
         class UpdateTimerTask extends TimerTask {
              public void run() {
                   SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                             dumpMemoryUsage();
         protected void dumpMemoryUsage() {
              System.gc();
              Long t = Runtime.getRuntime().totalMemory();
              long f = Runtime.getRuntime().freeMemory();
              String st = convertToStringRepresentation(t);
              String sf = convertToStringRepresentation(f);
              String su = convertToStringRepresentation(t - f);
              System.out.println("Total:" + st + "(" + t + ") Free:" + sf + "(" + f + ") Used:" + su + "(" + (t - f) + ")");
              lblMem.setText(su + "/" + st);
         public static String convertToStringRepresentation(final long value) {
              final long[] dividers = new long[]{T, G, M, K, 1};
              final String[] units = new String[]{"TB", "GB", "MB", "KB", "B"};
              if (value < 1)
                   throw new IllegalArgumentException("Invalid file size: " + value);
              String result = null;
              for (int i = 0; i < dividers.length; i++) {
                   final long divider = dividers;
                   if (value >= divider) {
                        final double dr = divider > 1 ? (double) value / (double) divider : (double) value;
                        result = df.format(dr) + units[i];
                        break;
              return result;
         private static void createAndShowGUI() {
              JFrame frame = new JFrame("SimpleTableDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              // Create and set up the content pane.
              TriState newContentPane = new TriState();
              newContentPane.setOpaque(true); // content panes must be opaque
              frame.setContentPane(newContentPane);
              // Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args) {
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGUI();
         protected class PopupMenu extends JPopupMenu {
              public PopupMenu() {
                   JRadioButtonMenuItem item1 = new JRadioButtonMenuItem(new AbstractAction("Insert Item") {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                             System.out.println(e.getActionCommand());
                   item1.setActionCommand("Insert");
                   add(item1);
                   JRadioButtonMenuItem item2 = new JRadioButtonMenuItem(new AbstractAction("Delete Item") {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                             System.out.println(e.getActionCommand());
                   item2.setActionCommand("Delete");
                   add(item2);
         public class FrmReferrals extends JFrame {
              public FrmReferrals() {
                   super();
                   init();
              protected void init() {
                   jbInit();
              protected void closeIt() {
                   uninit();
              // variables here
              protected Dimension          dimPreferred     = new Dimension(1270, 995);
              protected JTabbedPane     tabbedPane          = new JTabbedPane();
              protected JTable          tblReferrals     = null;
              protected PopupMenu          popMenu           = new PopupMenu();
              protected void jbInit() {
                   setPreferredSize(dimPreferred);
                   setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                   setTitle("Referrals");
                   JPanel pnl = new JPanel();
                   pnl.setOpaque(false);
                   pnl.setLayout(new BorderLayout());
                   pnl.add(tabbedPane, BorderLayout.CENTER);
                   // put it all in the frame
                   add(pnl);
                   pack();
                   setLocationRelativeTo(null);
                   // init the table and model
                   ReferralsTableModel ctm = new ReferralsTableModel(buildDummyVector());
                   tblReferrals = new JTable(ctm);
                   tblReferrals.setComponentPopupMenu(popMenu);
                   tblReferrals.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                   tabbedPane.add(new JScrollPane(tblReferrals, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
                   addWindowListener(new WindowListener() {
                        @Override
                        public void windowActivated(WindowEvent e) {}
                        @Override
                        public void windowClosed(WindowEvent e) {}
                        @Override
                        public void windowClosing(WindowEvent e) {
                             closeIt();
                        @Override
                        public void windowDeactivated(WindowEvent e) {}
                        @Override
                        public void windowDeiconified(WindowEvent e) {}
                        @Override
                        public void windowIconified(WindowEvent e) {}
                        @Override
                        public void windowOpened(WindowEvent e) {}
              protected Vector<DBO_Referrals> buildDummyVector() {
                   Vector<DBO_Referrals> vr = new Vector<DBO_Referrals>();
                   for (int x = 0; x < 5000; x++) {
                        DBO_Referrals r = new DBO_Referrals(x+(5000*ctr));
                        vr.add(r);
                   return vr;
              protected void uninit() {
                   tblReferrals.setComponentPopupMenu(null);
                   for (Component c : popMenu.getComponents()) {
                        PropertyChangeListener[] pl = c.getPropertyChangeListeners();
                        for (PropertyChangeListener l : pl)
                             c.removePropertyChangeListener(l);
                        if (c instanceof JMenuItem) {
                             ActionListener [] al = ((JMenuItem)c).getActionListeners();
                             for (ActionListener l : al) {
                                  ((JMenuItem)c).removeActionListener(l);
                   popMenu = null;
              protected class DBO_Referrals {
                   protected long          id;
                   protected String     Employee;
                   protected String     Rep;
                   protected String     Asst;
                   protected String     Client;
                   protected String     Dates;
                   protected String     Status;
                   protected String     Home;
                   public DBO_Referrals(long id) {
                        this.id = id;
                        Employee = "Employee" + id;
                        Rep = "Rep" + id;
                        Asst = "Asst" + id;
                        Client = "Client" + id;
                        Dates = "Dates" + id;
                        Status = "Status" + id;
                        Home = "Home" + id;
                   public long getId() {
                        return id;
                   public String getEmployee() {
                        return Employee;
                   public String getRep() {
                        return Rep;
                   public String getAsst() {
                        return Asst;
                   public String getClient() {
                        return Client;
                   public String getDates() {
                        return Dates;
                   public String getStatus() {
                        return Status;
                   public String getHome() {
                        return Home;
              public class ReferralsTableModel extends AbstractTableModel {
                   protected Vector<DBO_Referrals>          data          = new Vector<DBO_Referrals>();
                   protected String[]                         sColumns     = {"id", "Employee", "Rep", "Assistant", "Client", "Date", "Status", "Home", "R"};
                   public ReferralsTableModel() {
                        super();
                   public ReferralsTableModel(Vector<DBO_Referrals> data) {
                        this();
                        this.data = data;
                   @SuppressWarnings("unchecked")
                   @Override
                   public Class getColumnClass(int col) {
                        switch (col) {
                             case 0 :
                                  return Long.class;
                             default :
                                  return String.class;
                   @Override
                   public int getColumnCount() {
                        return sColumns.length;
                   @Override
                   public int getRowCount() {
                        return data.size();
                   @Override
                   public Object getValueAt(int row, int col) {
                        if (row > data.size())
                             return null;
                        DBO_Referrals a = data.get(row);
                        switch (col) {
                             case 0 :
                                  return a.getId();
                             case 1 :
                                  return a.getEmployee();
                             case 2 :
                                  return a.getRep();
                             case 3 :
                                  return a.getAsst();
                             case 4 :
                                  return a.getClient();
                             case 5 :
                                  return a.getDates();
                             case 6 :
                                  return a.getStatus();
                             case 7 :
                                  return a.getHome();
                             case 8 :
                                  return "+";
                             default :
                                  return null;

    BTW instead of continually printing out the memory use a profiler (jvisualvm in the jdk/bin directory -> heapdump -> search on your class -> view in instances -> find nearest GC root).
    Looks like BasicPopupMenuUI doesn't remove a reference to the JRootPane immediately. As far as I can see it will be removed when another menu shows.
    As a hackish workaround you can try this in you FrmReferrals#uninit():
                for(ChangeListener listener : MenuSelectionManager.defaultManager().getChangeListeners()) {
                    if (listener.getClass().getName().contains("MenuKeyboardHelper")) {
                        try {
                            Field field = listener.getClass().getDeclaredField("menuInputMap");
                            field.setAccessible(true);
                            field.set(listener, null);
                        } catch (Exception e) {
                            // ignored
                        break;
                }Funnily enough though it isn't there when I reduce your code to a SSCCE:
    import java.awt.*;
    import javax.swing.*;
    public class TestBasicPopupMenuUILeak extends JFrame {
        public TestBasicPopupMenuUILeak() {
            super("Not collected right away");
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.getContentPane().add(
                            new JButton(new AbstractAction("Show frame") {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    EventQueue.invokeLater(new Runnable() {
                                        public void run() {
                                            JLabel label = new JLabel(
    "Right click to show popup, then close this frame."
    + "The frame with not be GCed until another (popup) menu is shown.");
                                            JPopupMenu popup = new JPopupMenu(
                                                    "Popup");
                                            popup.add("Item");
                                            label.setComponentPopupMenu(popup);
                                            // named differently so you can find it
                                            // easily in your favorite profiler
                                            JFrame frame = new TestBasicPopupMenuUILeak();
                                            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                                            frame.getContentPane().add(label);
                                            frame.pack();
                                            frame.setLocationRelativeTo(null);
                                            frame.setVisible(true);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
    }

  • About Memory Leak in JAVA Any body pls help me

    Hi All,
    In our application, with JAVA we are using c, c++ native methods also.
    The problem is, Eventhough the application is in idle state, the Virtual Memory occupation is getting increased. For 24 hours, 30 MB is increased, while the application is in idle state.
    Is there any possiblity, this much memory leak can happen in JAVA. or it is from Native c side..
    I would appreciate anybody' s help.

    Thanks
    I am using JProfiler for that. I can observe what kind of objects not getting freed and the size of memory it is taking. and i observed thro JProfiler, that is only 16 kb of memory leak is happening. Can Any body who is well known about JProfiler help me. Can i differentiate the memory leak from JAVA and Native C side using JProfiler.
    Any help would be appreciated.

  • Memory Leaks in Java

    Hi,
    I have a considerably large business application that consists of JSPs and JavaBeans which connects to a database. The application runs off a Tomcat server. Some information about the application is as follows:
    a. JDK version 1.4.2_11
    b. Database used is MS SQL Server 2000 with Server pack 4
    c. Running on Tomcat version 4.1.31. Tomcat is being run under services.
    d. Third party libraries -
         Cryptix32
         i-Net Crystal Clear
         CeWolf and JFreeChart
         iText
         jxl
    I noticed that the Tomcat memory utilization increases after a period of using the application.
    I recently purchased JProbe as it was recommended as a good tool to check for memory leaks in Java applications. Having purchased Jprobe, the team is now proceeding to investigate the cause of the problem.
    I would like very much to seek the expertise of the community here as to some technique / steps the team should take during the course of the investigation.
    We are currently following the following steps:
    a. Startup JProbe
    b. Set a JProbe J2EE memory session which points to Tomcat and JDK
    c. Run the JProbe session
    d. Do a Collect Stack Trace
    e. Login to our application, execute a "single function" and then logout
    f. Do an Include Heapdump in Snapshot
    g. Save the snapshot
    h. Stop the JProbe session
    i. Investigate the output
    j. Repeat (c) to (i) for other functions in our application
    Would appreciate if the community here could advice if we are proceeding with the investigation correctly and whether we are missing out on any memory leaks. All suggestions are most welcome.
    Thanks.

    Hi,
    Just a bit more information about the application:
    Application contains:
    - 4490 JSP files
    - 1492 Java Classes
    Application Server:
    - Tomcat 4.1.31
    - JDK 1.4.2_11
    Database:
    - Microsoft SQL Server JDBC 2000
    - Microsoft SQL Server 2000 SP4
    Other JAR files:
    - Cryptix 32
    - jxl
    - CeWolf
    - i-Net Crystal Clear
    All items mentioned above is running on a Server with Microsoft Windows Server 2003 with 2GB of RAM.
    The JSP communicates to the JavaBean which in turn will connect to the Database via JDBC. We are not using connection pooling at the moment.
    The SQL Server takes around 1GB of ram and I have configured Tomcat with an Initial 250MB and a maximum of 750MB of RAM. Tomcat is running under NT services.
    Tomcat memory slowly increases and it takes around 4-7 weeks before it reaches the maximum memory and we get the out of memory error.
    We have done checking for memory leaks using JProbe but have not found any leaks in our program yet. We did find some of our classes were not closing the connection. I am not sure whether this could be the cause of the memory leak. We have also checked for static members in our classes and have not found anything wrong with them.
    Can anyone tell me whether:
    a) Is 2GB RAM sufficient for this type of configuration?
    b) If we add more RAM will it be more beneficial?
    c) Our Tomcat web.xml configuration. Reloadable = true, Development = true. Will this cause memory leaks?
    d) Should we upgrade to Tomcat 5 or 6?
    e) Should we upgrade the JDBC Driver to 2005?
    f) Should we upgrade the version of JDK to 1.5 or 1.6?
    g) Is it recommended to restart Tomcat every now and then?
    Thanks.

  • Memory Leak in  Java

    Anyone can suggest what is the best way to test memory leak in JAVA?
    Thanks in advance for the help.

    I'll try to define it for the OP
    Define: memory leakhttp://en.wikipedia.org/wiki/Memory_leak
    Define: bestDoesn't really apply but wondered what wikipedia would return: http://en.wikipedia.org/wiki/Best
    Define: testhttp://en.wikipedia.org/wiki/Software_testing

  • Memory leaks with Third party classes

    Hello all,
    This is fairly known problem. But I guess, my problem gives a new dimention to the problem.
    I have an application which is developed by me. This application ideally needed to use third party classes ( obviously no source code is supplied ). These third party classes provide extra functionality required.
    The problem is, when I don't use third party classes in my application, every thing is fine. When I include third party classes, I am having memory leaks.
    Then I tried to investigate memory leaks with Optimizeit tool. It is new to me. As of now, I understood, we can identify where the memory leaks are occuring.
    finally the problem is, in order to solve this, I need some patches in the code. But I don't have source code for those classes. How to solve this problem?
    For example,
    I use a third party classes in my code like this,
    ThirdPartyMemoryLeakClass obj = new ThirdPartyMemoryLeakClass();
    This 'obj' is made static, as it takes lot of time to create this object. Obviously this object contains several references to other objects, which I can't control.
    In the process of reusing this object, I am getting memory leaks.
    Any ideas regarding, how one has to deal this type of situations? What are the issues involved with this case? Are there any similar problems, which have been solved? are most welcome.
    many thanks for your time.
    Madhav

    Decompile it using jad. Find leak.Yes, I too got the idea and tried to decompile those classes and recompile. I had some problems while recompiling. Is this is the only way to get rid of this problem?
    I was refering to powersoft.datawindow.DataStore class. Does any body here has worked on these?
    Can you suggest me how to find the memory leak causes? if you were needed to find out memory leak causes, what would be your approach?
    Madhav

  • Possible causes for memory leak in Java and Tomcat

    I would like to enquire what are the typical mistakes done by programmers that will cause memory leak in Java and Tomcat.

    Please refer the below site. It will give more points about the memory leak and how to rectify it.
    http://www.experts-exchange.com/Software/Server_Software/Application_Servers/Q_20981562.html?cid=336

  • Memory Leak with JDialog in Java 1.4.2_07

    Hello!
    All books I have read say to close a JDialog, it is enough to call the Method "dispose". Now I have written my first applikation an with every Dialog I open, the Software needs more RAM. With every Dialog I open, my software needs 1,5 MB RAM.
    I can`t reuse the Dialogs, because the user needs to look at view at the same time
    The Question is, how to close a JDialog correct that the GC can clean all Objects in RAM.
    Here are my Example Programm where you can view the differences. I tryed a view things out. With every Dialog the software needs xxx kb of RAM (its only a little example).
    Look at the Task Manager to look the real RAM needage.
    Thanks for Help
    Rainer
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    public class TestRAMUsage extends JFrame {
         private JPanel jContentPane = null;
         private JMenuBar jJMenuBar = null;
         private JMenu fileMenu = null;
         private JMenuItem exitMenuItem = null;
         private JButton jB_showandclose_normal = null;
         private JButton jB_showandclose_advanced = null;
          * This method initializes jB_showandclose_normal     
          * @return javax.swing.JButton     
         private JButton getJB_showandclose_normal() {
              if (jB_showandclose_normal == null) {
                   jB_showandclose_normal = new JButton();
                   jB_showandclose_normal.setBounds(new java.awt.Rectangle(43,30,214,18));
                   jB_showandclose_normal.setText("open/close Dialog normal x 50");
                   jB_showandclose_normal.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             for (int i = 0; i < 50; i++) {
                                  TestDialog td = new TestDialog();
                                  td.show();
                                  td.close_normal();
                             System.gc();
              return jB_showandclose_normal;
          * This method initializes jB_showandclose_advanced     
          * @return javax.swing.JButton     
         private JButton getJB_showandclose_advanced() {
              if (jB_showandclose_advanced == null) {
                   jB_showandclose_advanced = new JButton();
                   jB_showandclose_advanced.setBounds(new java.awt.Rectangle(16,76,260,18));
                   jB_showandclose_advanced.setText("open/close Dialog advanced x 50");
                   jB_showandclose_advanced.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             for (int i = 0; i < 50; i++) {
                                  TestDialog td = new TestDialog();
                                  td.show();
                                  td.close_advanced();
                             System.gc();
              return jB_showandclose_advanced;
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              TestRAMUsage application = new TestRAMUsage();
              application.show();
          * This is the default constructor
         public TestRAMUsage() {
              super();
              initialize();
          * This method initializes this
          * @return void
         private void initialize() {
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setJMenuBar(getJJMenuBar());
              this.setSize(300, 200);
              this.setContentPane(getJContentPane());
              this.setTitle("Application");
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(null);
                   jContentPane.add(getJB_showandclose_normal(), null);
                   jContentPane.add(getJB_showandclose_advanced(), null);
              return jContentPane;
          * This method initializes jJMenuBar     
          * @return javax.swing.JMenuBar     
         private JMenuBar getJJMenuBar() {
              if (jJMenuBar == null) {
                   jJMenuBar = new JMenuBar();
                   jJMenuBar.add(getFileMenu());
              return jJMenuBar;
          * This method initializes jMenu     
          * @return javax.swing.JMenu     
         private JMenu getFileMenu() {
              if (fileMenu == null) {
                   fileMenu = new JMenu();
                   fileMenu.setText("File");
                   fileMenu.add(getExitMenuItem());
              return fileMenu;
          * This method initializes jMenuItem     
          * @return javax.swing.JMenuItem     
         private JMenuItem getExitMenuItem() {
              if (exitMenuItem == null) {
                   exitMenuItem = new JMenuItem();
                   exitMenuItem.setText("Exit");
                   exitMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                             System.exit(0);
              return exitMenuItem;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class TestDialog extends JDialog {
         private static final long serialVersionUID = -4326706771573368209L;
         private JPanel jContentPane = null;
         private JButton jB_drucken = null;
         private JTextField jTF_hallo = null;
         private JButton jB_close = null;
          * This is the default constructor
         public TestDialog() {
              super();
              initialize();
          * This method initializes this
          * @return void
         private void initialize() {
              this.setSize(541, 255);
              this.setTitle("Speicher Dialog");
              this.setContentPane(getJContentPane());
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(null);
                   jContentPane.add(getJB_drucken(), null);
                   jContentPane.add(getJTF_hallo(), null);
                   jContentPane.add(getJB_close(), null);
              return jContentPane;
          * This method initializes jB_drucken
          * @return javax.swing.JButton
         private JButton getJB_drucken() {
              if (jB_drucken == null) {
                   jB_drucken = new JButton();
                   jB_drucken.setBounds(new java.awt.Rectangle(45, 88, 211, 19));
                   jB_drucken.setText("Sag Hallo Welt");
              return jB_drucken;
          * This method initializes jTF_hallo
          * @return javax.swing.JTextField
         private JTextField getJTF_hallo() {
              if (jTF_hallo == null) {
                   jTF_hallo = new JTextField();
                   jTF_hallo.setBounds(new java.awt.Rectangle(269, 88, 228, 19));
              return jTF_hallo;
          * This method initializes jB_close
          * @return javax.swing.JButton
         private JButton getJB_close() {
              if (jB_close == null) {
                   jB_close = new JButton();
                   jB_close.setBounds(new java.awt.Rectangle(196, 179, 109, 22));
                   jB_close.setText("Schlie�en");
                   jB_close.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             try {
                                  // setVisible(false);
                                  dispose();
                                  removeAll();
                                  // getContentPane().removeAll();
                                  // finalize();
                             } catch (Throwable e1) {
                                  // TODO Auto-generated catch block
                                  e1.printStackTrace();
              return jB_close;
          * Dispose the Dialog
         public void close_normal() {
              dispose();
          * Set all Variables to null
          * Remove all Container
          * dispose the Dialog
          * and finalize it!
         public void close_advanced() {
              // System.out.println(this.);
              dispose();
              // show();
              jContentPane = null;
              jB_drucken = null;
              jTF_hallo = null;
              jB_close = null;
              getContentPane().removeAll();
              removeAll();
              try {
                   finalize();
              } catch (Throwable e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    } // @jve:decl-index=0:visual-constraint="10,10"

    I have use Methods in some Software Produkts. But if your Software
    use 30 MB in RAM the Runtime classes say 12 MB used. I don`t think
    that this works hereThe 12 MB is the memory used of the available 30 MB memory available. Once the VM get its memory from the OS, it does not have to return the memory back to the OS right away.
    By calling System.gc() does nt guarentee the garbage collector to be activated right away. you are just asking the garbage collector to run when it get a chance. Since the emeory is not near the max memory available...the gc is likely not going to run. Futhermore, if your application is running..the gc is likely wont run, unless memory is needed when you reach the max limit.
    because the user want to view at more than one Dialog at the same
    timeunderstandable..i just hope the 50 dialogs is just for testing the memory. i can't imagine any user would want to open 50 dialog at the same time =)
    And the other is, that the Variables in the Dialog class wouldn`t clean
    in RAM (that was the reason to set all to null!)why would it not be? When you dispose the dialog, the object will be null out..so when the garbage collector kick in, it will reclaim the memory. Now, if you have references to object in the dialog, that reference will be null out as well..the object may still exist (by having another live object having a reference to it)...the garbage collector would reclaim the dialog memory..but not the "live" object that the dialog has reference to.
    I ran the application..testing both button.
    The top button..there were little memory consumption..the second button consume a little memory bit-by-bit. I see no memory leak here. What happens is you called GC() 50 times..but it will only run one time when it get a chance...by nulling out the variables, and calling finalize()..it actually slow down the garbage collecting...that's why you should not even obther with having those two method. Furthermore, finalize method may not even be called.
    Memory leak occurs when you have a reference from an object still hanging around, but that object is no longer needed. This is a design issue.
    example
    public class A{
        Item item = new Item();
        public void getItem(){ return item; };
    public class B{
        Item item;
        public B(A a){
            item = a.getItem();
    A a = new A();
    B b = new B(a);
    a = null;when a is null out..the item reference is null, but the actual object still exist and 'b' has a reference to it. so by nulling out those object does not mean you just got rid of the object. it's better to let the object scope run out..and the garbage collector to collect it.. When you null out the object, you could accidentally null out an object that some other object may be using.

  • Memory Leak with 4.5.1/Java/Solaris

    Hi,
    We are currently running a Java Application using RMI/Weblogic 4.5.1/Solaris 5.7/Java 1.22.
    Behavior that has been observered during the day is that memory usage reaches a stage in which it begins increasing and GC doesn't recover any memory, until the heap reaches an extremly large size, then recovers a significant amount of memory.
    We have even seen the java process grab more memory than specified in the -Xmx parameter and experience a java.lang.OutOfMemory error.
    I have seen postings that describe similar issues in this newsgroup, but none that define a solution.
    This problem is intermittent, and our application can run an entire day without experiencing this memory leak. On the other hand there are days when the memory leak occurrs even when the system is idle overnight.
    Please let me know any information you have gathered on this subject.
    Regards,
    Mark Evans

    try increasing your virtual memory on your NT system...
    "Parasher K. Joshi" <[email protected]> wrote:
    >
    Hi,
    I observed the same confusing stuff in my tests. But I run weblogic 4.5.1 on Windows NT with JDK 1.2.2-w
    Usually, I would get a "Low virtual memory" message from windows
    and if I click ok & shuffle thourgh my windows I would be ok.
    But since last 2 days, I would keep the server running overnight.
    When I return in morning,
    I would find a "Low virtual memory" message and
    on clicking OK. I would find another message tell me that java.exe (which was running weblogic) crashed!!
    Now today I tried to watch the memory usage in Task Manager. And I found the most wierd thing.
    I saw that even when the system was doing virtually nothing,
    except print a string at intervals, the memory usage would go
    up steadyly.
    Even doing a forced finalization and gc did not seem to stop it.
    BUT, BY CHANCE I HAPPEN TO MINIMISE AND MAXIMISE THE WEBLOGIC
    CONSOLE OUTPUT WINDOW.
    WHAT I SAW IN THE TASK MANAGER AMAZED ME!
    THE MEMORY USAGE IN TASK MANAGER HAD GONE DOWN TO 24XXKB, WHILE
    IT WAS ABOUT 20000K OR EVEN MORE.
    This seems to support the fact that during my test, I would
    get the "low virtual memory" message and if OKed it and shuffled
    though application windows (maybe minimise, maximise the weblogic
    console output window in process), I would be able to complete
    my application. But when the message appears during night runs,
    nothing is done and by morning, when I reach to work,
    I would see that weblogic had crashed!!
    You may try that and see if it helps you.
    Parasher
    Mark Evans <[email protected]> wrote:
    Hi,
    We are currently running a Java Application using RMI/Weblogic 4.5.1/Solaris 5.7/Java 1.22.
    Behavior that has been observered during the day is that memory usage reaches a stage in which it begins increasing and GC doesn't recover any memory, until the heap reaches an extremly large size, then recovers a significant amount of memory.
    We have even seen the java process grab more memory than specified in the -Xmx parameter and experience a java.lang.OutOfMemory error.
    I have seen postings that describe similar issues in this newsgroup, but none that define a solution.
    This problem is intermittent, and our application can run an entire day without experiencing this memory leak. On the other hand there are days when the memory leak occurrs even when the system is idle overnight.
    Please let me know any information you have gathered on this subject.
    Regards,
    Mark Evans

  • Memory Leak in Java Server

    Howdy Folks- I wrote a server monitor in java, which I was expecting to run for months at a time without restarting. Apparently there is some slow memory leak which results in an OutOfMemoryError after a few weeks. It's in a production system, so I can't readily add debug statements to the code, and the OutOfMemoryError apparently screwed up the logging, so I didn't get a stack trace in my logs, just an "OutOfMemoryError" went to standard out.
    I'm assuming the problem lies in the code, specifically probably some discarded reference that is not being properly garbage collected? I am using a few different ArrayLists to store some historical information, and I call clear() on these frequently. Is there any known issue with ArrayList or HashMap that the "clear()" method doesn't result in garbage collection of the objects that were in it? I am also doing a "remove(int)" sometimes as well. Any chance the objects cleared or removed would not be garbage collected?
    thanks
    Bleu

    Howdy Folks- I wrote a server monitor in java, which I
    was expecting to run for months at a time without
    restarting. Apparently there is some slow memory leak
    which results in an OutOfMemoryError after a few
    weeks. It's in a production system, so I can't
    readily add debug statements to the code, and the
    OutOfMemoryError apparently screwed up the logging, so
    I didn't get a stack trace in my logs, just an
    "OutOfMemoryError" went to standard out.Are you even attempting to catch Errors? Catching Exceptions will not help with this. It should print the stack trace. When it OOMs it doesn't mess up what's already allocated, it just can't allocate more.
    I'm assuming the problem lies in the code,
    specifically probably some discarded reference that is
    not being properly garbage collected? Most likely, there are references that are never being cleared in your code. Without seeing the code or at least having a better description, I don't think anyone here can help you. Can you set up a test senario and use an Optimizer to see what's going on?
    I am using a
    few different ArrayLists to store some historical
    information, and I call clear() on these frequently.
    Is there any known issue with ArrayList or HashMap
    that the "clear()" method doesn't result in garbage
    collection of the objects that were in it? Not that I know of, no. I doubt that is the problem.

  • Memory Leak with new Font()

    Hello all,
    Not sure if this is the right place to post this but here goes. I have a program that needs to change the font of at least 250,000 letters, however after doing this the program runs slow and laggy as if changing the fonts of each letter took up memory and never released it? Here is a compilable example, Click the button at the bottom of the window and watch the letter it is currently working on. You will notice that around 200,000 it will begin to not smoothly count up anymore but count in kind of a skipping pattern. This seems to get worse the more you do it and seems to indicate to me that something is using memory and not releasing it. I'm not sure why replacing a letter's font with a new font would cause more memory to be taken up I would think if I was doing it properly it would simply replace the old font with the new one not taking anymore memory then it did before. Here is the example: This program sometimes locks up so be prepared. If someone could maybe point out what is causing this to take up more memory after changing the fonts that would be great and hopefully find a solution :) Thanks in advance.
    -neptune692
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package paintsurface;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.util.List;
    public class PaintSurface implements Runnable, ActionListener {
    public static void main(String[] args) {
            SwingUtilities.invokeLater(new PaintSurface());
    List<StringState> states = new ArrayList<StringState>();
    Tableaux tableaux;
    Random random = new Random();
    Font font = new Font("Arial",Font.PLAIN,15);
    //        Point mouselocation = new Point(0,0);
    static final int WIDTH = 1000;
    static final int HEIGHT = 1000;
    JFrame frame = new JFrame();
    JButton add;
    public void run() {
            tableaux = new Tableaux();
            for (int i=250000; --i>=0;)
                    addRandom();
            frame.add(tableaux, BorderLayout.CENTER);
            add = new JButton("Change Font of letters - memory leak?");
            add.addActionListener(this);
            frame.add(add, BorderLayout.SOUTH);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(WIDTH, HEIGHT);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    public void actionPerformed(ActionEvent e) {
        new Thread(new ChangeFonts()).start();
    void addRandom() {
            tableaux.add(
                            Character.toString((char)('a'+random.nextInt(26))),
                            UIManager.getFont("Button.font"),
                            random.nextInt(WIDTH), random.nextInt(HEIGHT));
    //THIS CLASS SEEMS TO HAVE SOME KIND OF MEMORY LEAK I'M NOT SURE?
    class ChangeFonts implements Runnable {
        public void run() {
        Random rand = new Random();
            for(int i = 0; i<states.size(); i++) {
                font = new Font("Arial",Font.PLAIN,rand.nextInt(50));
                states.get(i).font = font;
                add.setText("Working on letter - "+i);
    class StringState extends Rectangle {
            StringState(String str, Font font, int x, int y, int w, int h) {
                    super(x, y, w, h);
                    string = str;
                    this.font = font;
            String string;
            Font font;
    class Tableaux extends JComponent {
            Tableaux() {
                    this.enableEvents(MouseEvent.MOUSE_MOTION_EVENT_MASK);
                    lagState = createState("Lag", new Font("Arial",Font.BOLD,20), 0, 0);
            protected void processMouseMotionEvent(MouseEvent e) {
                    repaint(lagState);
                    lagState.setLocation(e.getX(), e.getY());
                    repaint(lagState);
                    super.processMouseMotionEvent(e);
            StringState lagState;
            StringState createState(String str, Font font, int x, int y) {
                FontMetrics metrics = getFontMetrics(font);
                int w = metrics.stringWidth(str);
                int h = metrics.getHeight();
                return new StringState(str, font, x, y-metrics.getAscent(), w, h);
            public void add(String str, Font font, int x, int y) {
                    StringState state = createState(str, font, x, y);
                    states.add(state);
                    repaint(state);
            protected void paintComponent(Graphics g) {
                    Rectangle clip = g.getClipBounds();
                    FontMetrics metrics = g.getFontMetrics();
                    for (StringState state : states) {
                            if (state.intersects(clip)) {
                                    if (!state.font.equals(g.getFont())) {
                                            g.setFont(state.font);
                                            metrics = g.getFontMetrics();
                                    g.drawString(state.string, state.x, state.y+metrics.getAscent());
                    if (lagState.intersects(clip)) {
                    g.setColor(Color.red);
                    if (!lagState.font.equals(g.getFont())) {
                        g.setFont(lagState.font);
                        metrics = g.getFontMetrics();
                    g.drawString("Lag", lagState.x, lagState.y+metrics.getAscent());
    }Here is the block of code that I think is causing the problem:
    //THIS CLASS SEEMS TO HAVE SOME KIND OF MEMORY LEAK I'M NOT SURE?
    class ChangeFonts implements Runnable {
        public void run() {
        Random rand = new Random();
            for(int i = 0; i<states.size(); i++) {
                font = new Font("Arial",Font.PLAIN,rand.nextInt(50));
                states.get(i).font = font; // this line seems to cause the problem?
                add.setText("Working on letter - "+i);
    }

    neptune692 wrote:
    jverd wrote:
    You're creating a quarter million distinct Font objects, and obviously you must be hanging on to all of them because each character is having its font set to the newly created object. So if you have 250k chars, you're forcing it to have 250k Font objects.
    Since the only difference is that rand.nextInt(50) parameter, just pre-create 50 Font objects with 0..49, stick 'em in the corresponding elements in an array, and use rand.nextInt to select the Font object to use.That does make sense but it does that when the the program is first launched and doesn't lag. But the second and third time you change the letters font it seems to lag so if it wasn't taking up more memory the second time it should perform like it did when it first launched. I don't care to investigate any further. The real problem is almost certainly the quarter million Font objects. It could be that 250k is fine, but by the time you get to 500k, it has to do a lot of GC, and that's where the slow down is coming. You might even be able to make it work better with the code you have just by tweaking the GC parameters at startup, but I wouldn't bother. Fix the code first, and then see if you have issues.
    Does creating a new font for each of those letters not replace the old font object? If it didn't use more memory the second and third time I don't think you would see the skipping in the counter and the slowing down of the iterations. So it must be remembering some of the old font objects or am I wrong?Using new always creates a new object. When you do it the second time around, and call letter.setFont(newFont), the old Font object is eligible for GC. That doesn't mean it will be GCed right away though. The JVM can leave them all laying around until it runs out of memory, and then GC some or all of them.

Maybe you are looking for

  • AUTOMATIC CLEARING OF CENVAT ACCOUNT

    Hi Fnds, I am using F.13 for automatic clearing. In OB74, i have given Acc. Type as 'S' , given acct. number, Criterion 1- EBELN-Purchasing Doc. Criterion 2- EBELP-Item Criterion 3- MATNR-Material Criterion 4- XBLNR- Reference. Still the items are no

  • Blocked plug-ins java

    Does anybody know how to reset or enable jave plug in after I have down loaded the updated version? Thanks

  • Exceptions in Bex

    I have a requirement : The variance between Actuals and budget should have exceptions,such that, when actuals >budget -> Green and When Actuals < budget -> red. there are some scenarios, 1.Actuals and buget can be both positive 2. both negative 3. Ac

  • I am having trouble opening Firefox. Is anyone else? Are they down for repairs?

    When I try to open Firefox it times out and I get an error message stating there's a problem opening the page. Also, it times out with the following as the page location: http://flyingincognitosleep.com/cgi-bin/h.plp. I can open Internet Explorer. I

  • Need an iCloud version for windows 8 64-bit pc

    I'm looking for an iCloud download for windows 8 64-bit pc. Where do I get one?