Memory Leak with Weblogic 6.1

Hello everyone.
I need some help with a problem we are having with our application. It consists on Servlets, JMS with MDBs, Xml parsing...
Our application dequeues messages from an Oracle Queue and sends xml-text message to a servlet. It also receives xml-text and enqueues objects in an Oracle Queue.
And it also has access to Oracle Database (context tables, etc).
We are doing everything on Tru64 Unix (and our tests on Win 2000) and we are using WebLogic 6.1.
Our problem is that we have found that it seems that the garbage collector is not running well. I mean, with the time our system is degrading. The memory use increases. It seems to be a memory leak.
We have used a testing tool, OptimizeIt, and we have found that there are
objects that are increasing the use of memory. If we use the option 'java -verbose' we find that it seems to be Hash objects (HashMap, Hashtable) which are increasing the use of memory. In our code we are not using any hashtable nor any class that extends from it (we have deleted everyone).
Can it be due to a problem with WebLogic? A problem with JMS, queues, etc? A problem with JNDI?
Could anybody please help us?
Thanks in advanced.

Yes, we see that there are some entries of the type:
java/util/Hahstable$Entry
java/util/Hahstable
weblogic/jndi/Environment
This entries keep growing and growing with the time.
We have deleted all the Hashtable, Properties and all the kind of Collection objects. I guess WebLogic is using this objects in order to arrange our application runs.
Am I right? Do you know if we can do anything?
Thank you.

Similar Messages

  • 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

  • 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 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 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);
    }

  • Memory leak in weblogic 6.0 sp2 oracle 8.1.7 thin driver

    Hi,
         I have a simple client that opens a database connection, selects from
    a table containing five rows of data (with four columns in each row)
    and then closes all connections. On running this in a loop, I get the
    following error after some time:
    <Nov 28, 2001 5:57:40 PM GMT+06:00> <Error> <Adapter>
    <OutOfMemoryError in
    Adapter
    java.lang.OutOfMemoryError
    <<no stack trace available>>
    >
    <Nov 28, 2001 5:57:40 PM GMT+06:00> <Error> <Kernel> <ExecuteRequest
    failed
    java.lang.OutOfMemoryError
    I am running with a heap size of 64 Mb. The java command that runs
    the client is:
    java -ms64m -mx64m -cp .:/opt/bea/wlserver6.0/lib/weblogic.jar
    -Djava.naming.f
    actory.initial=weblogic.jndi.WLInitialContextFactory
    -Djava.naming.provider.url=
    t3://garlic:7001 -verbose:gc Test
    The following is the client code that opens the db connection and does
    the select:
    import java.util.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.*;
    public class Test {
    private static final String strQuery = "SELECT * from tblPromotion";
    public static void main(String argv[])
    throws Exception
    String ctxFactory     = System.getProperty
    ("java.naming.factory.initial");
    String providerUrl     = System.getProperty
    ("java.naming.provider.url");
    Properties jndiEnv          = System.getProperties ();
    System.out.println ("ctxFactory : " + ctxFactory);
    System.out.println ("ProviderURL : " + providerUrl);
    Context ctx     = new InitialContext (jndiEnv);
    for (int i=0; i <1000000; i++)
    System.out.println("Running query for the "+i+" time");
    Connection con = null;
    Statement stmnt = null;
    ResultSet rs     = null;
    try
    DataSource ds     = (DataSource) ctx.lookup
    (System.getProperty("eaMDataStore", "jdbc/eaMarket"));
    con = ds.getConnection ();
    stmnt = con.createStatement();
    rs = stmnt.executeQuery(strQuery);
    while (rs.next ())
    //System.out.print(".");
    //System.out.println(".");
    ds = null;
    catch (java.sql.SQLException sqle)
    System.out.println("SQL Exception : "+sqle.getMessage());
    finally
    try {
    rs.close ();
    rs = null;
    //System.out.println("closed result set");
    } catch (Exception e) {
    System.out.println("Exception closing result set");
    try {
    stmnt.close ();
    stmnt = null;
    //System.out.println("closed statement");
    } catch (Exception e) {
    System.out.println("Exception closing result set");
    try {
    con.close();
    con = null;
    //System.out.println("closed connection");
    } catch (Exception e) {
    System.out.println("Exception closing connection");
    I am using the Oracle 8.1.7 thin driver. Please let me know if this
    memory leak is a known issue or if its something I am doing.
    thanks,
    rudy

    Repost in JDBC section ... very serious issue but it may be due to Oracle or
    to WL ... does it happen if you test inside WL itself?
    How many iterations does it take to blow? How long? Does changing to a
    different driver (maybe Cloudscape) have the same result?
    Peace,
    Cameron Purdy
    Tangosol Inc.
    << Tangosol Server: How Weblogic applications are customized >>
    << Download now from http://www.tangosol.com/download.jsp >>
    "R.C." <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    I have a simple client that opens a database connection, selects from
    a table containing five rows of data (with four columns in each row)
    and then closes all connections. On running this in a loop, I get the
    following error after some time:
    <Nov 28, 2001 5:57:40 PM GMT+06:00> <Error> <Adapter>
    <OutOfMemoryError in
    Adapter
    java.lang.OutOfMemoryError
    <<no stack trace available>>
    >
    <Nov 28, 2001 5:57:40 PM GMT+06:00> <Error> <Kernel> <ExecuteRequest
    failed
    java.lang.OutOfMemoryError
    I am running with a heap size of 64 Mb. The java command that runs
    the client is:
    java -ms64m -mx64m -cp .:/opt/bea/wlserver6.0/lib/weblogic.jar
    -Djava.naming.f
    actory.initial=weblogic.jndi.WLInitialContextFactory
    -Djava.naming.provider.url=
    t3://garlic:7001 -verbose:gc Test
    The following is the client code that opens the db connection and does
    the select:
    import java.util.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.*;
    public class Test {
    private static final String strQuery = "SELECT * from tblPromotion";
    public static void main(String argv[])
    throws Exception
    String ctxFactory = System.getProperty
    ("java.naming.factory.initial");
    String providerUrl = System.getProperty
    ("java.naming.provider.url");
    Properties jndiEnv = System.getProperties ();
    System.out.println ("ctxFactory : " + ctxFactory);
    System.out.println ("ProviderURL : " + providerUrl);
    Context ctx = new InitialContext (jndiEnv);
    for (int i=0; i <1000000; i++)
    System.out.println("Running query for the "+i+" time");
    Connection con = null;
    Statement stmnt = null;
    ResultSet rs = null;
    try
    DataSource ds = (DataSource) ctx.lookup
    (System.getProperty("eaMDataStore", "jdbc/eaMarket"));
    con = ds.getConnection ();
    stmnt = con.createStatement();
    rs = stmnt.executeQuery(strQuery);
    while (rs.next ())
    //System.out.print(".");
    //System.out.println(".");
    ds = null;
    catch (java.sql.SQLException sqle)
    System.out.println("SQL Exception : "+sqle.getMessage());
    finally
    try {
    rs.close ();
    rs = null;
    //System.out.println("closed result set");
    } catch (Exception e) {
    System.out.println("Exception closing result set");
    try {
    stmnt.close ();
    stmnt = null;
    //System.out.println("closed statement");
    } catch (Exception e) {
    System.out.println("Exception closing result set");
    try {
    con.close();
    con = null;
    //System.out.println("closed connection");
    } catch (Exception e) {
    System.out.println("Exception closing connection");
    I am using the Oracle 8.1.7 thin driver. Please let me know if this
    memory leak is a known issue or if its something I am doing.
    thanks,
    rudy

  • 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 w/ WebLogic 5.1

    I've created a simple servlet to EJB skeleton and built a stress testing
              tool to make sequential requests to the servlet which in turn creates an
              instance of a stateless session been. Both the servlet and bean do not have
              any real logic in them, just some minimal timing output.
              When run for a few million iterations, the WebLogic JVM slowly leaks memory
              that cannot be reclaimed even with force garbage collection from the
              WebLogic console. Below are 3 snippets of code showing the servlet, the EJB
              call, and the simple client test.
              If anyone else is ecperiencing similar problems or can see a flaw, I'd be
              most grateful.
              Andy
              Servlet code
              protected void doGet(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException
              TestBean bean;
              long requestStartTime = System.currentTimeMillis();
              res.setContentType("text/html");
              PrintWriter out = res.getWriter();
              out.println("<html><head><title>Hello World!</title></head>");
              out.println("<body><h1>Hello World!</h1></body></html>");
              try {
              bean = home.create();;
              bean.testMethod();
              catch (Exception e) {
              totalTime += (System.currentTimeMillis() - requestStartTime);
              Bean code
              public class TestBean implements SessionBean {
              private SessionContext ctx;
              public void ejbActivate() {
              public void ejbPassivate() {
              public void ejbCreate() {
              public void ejbRemove() {
              public void setSessionContext(SessionContext ctx) {
              this.ctx = ctx;
              public void testMethod() {
              Client code
              public void simulateLoad()
              throws IOException
              long totalRequestTime = 0, requestTime, requestStartTime;
              long totalResponseTime = 0, responseTime, responseStartTime;
              try {
              log("Opening connection to "+ url + (debug ? "?debug=true" : ""));
              for (int i = 1; i <= numRequests; i++) {
              HTTPConnection con = new HTTPConnection("localhost",7001);
              HTTPResponse rsp;
              byte data[];
              if ((i % 10000) == 0) {
              log("\nGET Request "+i+" to "+ url + (debug ? "?debug=true" :
              requestStartTime = System.currentTimeMillis();
              rsp = con.Get("/mcumanager" + (debug ? "?debug=true" : ""));
              requestTime = System.currentTimeMillis() - requestStartTime;
              responseStartTime = System.currentTimeMillis();
              if (rsp.getStatusCode() >= 300) {
              log("Received Error: "+rsp.getReasonLine());
              log(new String(rsp.getData()));
              else
              data = rsp.getData();
              responseTime = System.currentTimeMillis() - responseStartTime;
              totalRequestTime += requestTime;
              totalResponseTime += responseTime;
              if ((i % 10000) == 0) {
              log("GET Response "+i+": "+rsp);
              if ((i % 100) == 0) {
              log ("Avg request time :
              "+((float)totalRequestTime/(float)i)+"ms");
              log ("Avg response time :
              "+((float)totalResponseTime/(float)i)+"ms");
              catch (IOException ioe) {
              log(ioe.toString());
              ioe.printStackTrace();
              catch (ModuleException me) {
              log("Error handling request: " + me.getMessage());
              me.printStackTrace();
              

    Please read discussion "WLS dies during stress testing" & "performance
              degradation PROBLEM" in interest.performance.
              Hope it helps.
              Cheers - Wei
              Andy Riedel <[email protected]> wrote in message
              news:[email protected]...
              > I have additional information on this problem. I have replicated the exact
              > same memory leak issue using the included HelloWorldServlet. I use Jrun's
              > ServletKiller stress tool running 16 simultaneous request threads
              requesting
              > the HelloWorldServlet. This WebLogic 5.1 server will leak memory and
              > eventually run out of memory all together with an OutOfMemoryException
              after
              > about 6-8 hours. This indicates that the bug is in the base HTTP Servlet
              > engine code.
              >
              > I have tried turning off the http log (i.e. access.log) as well as
              > notification events from the servlet engine and it still leaks memory.
              >
              > Andy
              >
              >
              >
              > Andy Riedel Chief Architect HearMe Call me through VoiceCONTACTtm -- right
              > from your computer. Online Status:
              > "Andy Riedel" <[email protected]> wrote in message
              > news:[email protected]...
              > > I've created a simple servlet to EJB skeleton and built a stress testing
              > > tool to make sequential requests to the servlet which in turn creates an
              > > instance of a stateless session been. Both the servlet and bean do not
              > have
              > > any real logic in them, just some minimal timing output.
              > >
              > > When run for a few million iterations, the WebLogic JVM slowly leaks
              > memory
              > > that cannot be reclaimed even with force garbage collection from the
              > > WebLogic console. Below are 3 snippets of code showing the servlet, the
              > EJB
              > > call, and the simple client test.
              > >
              > > If anyone else is ecperiencing similar problems or can see a flaw, I'd
              be
              > > most grateful.
              > >
              > > Andy
              > >
              > >
              > > Servlet code
              > > -------------
              > >
              > > protected void doGet(HttpServletRequest req, HttpServletResponse res)
              > > throws ServletException, IOException
              > > {
              > > TestBean bean;
              > >
              > > long requestStartTime = System.currentTimeMillis();
              > >
              > > res.setContentType("text/html");
              > > PrintWriter out = res.getWriter();
              > > out.println("<html><head><title>Hello World!</title></head>");
              > > out.println("<body><h1>Hello World!</h1></body></html>");
              > >
              > > try {
              > > bean = home.create();;
              > > bean.testMethod();
              > > }
              > > catch (Exception e) {
              > > }
              > >
              > > totalTime += (System.currentTimeMillis() - requestStartTime);
              > > }
              > >
              > > Bean code
              > > -----------
              > > public class TestBean implements SessionBean {
              > >
              > > private SessionContext ctx;
              > >
              > > public void ejbActivate() {
              > > }
              > >
              > > public void ejbPassivate() {
              > > }
              > >
              > > public void ejbCreate() {
              > > }
              > >
              > > public void ejbRemove() {
              > > }
              > >
              > > public void setSessionContext(SessionContext ctx) {
              > > this.ctx = ctx;
              > > }
              > >
              > > public void testMethod() {
              > > }
              > > }
              > >
              > > Client code
              > > ------------
              > > public void simulateLoad()
              > > throws IOException
              > > {
              > > long totalRequestTime = 0, requestTime, requestStartTime;
              > > long totalResponseTime = 0, responseTime, responseStartTime;
              > >
              > > try {
              > > log("Opening connection to "+ url + (debug ? "?debug=true" : ""));
              > >
              > > for (int i = 1; i <= numRequests; i++) {
              > >
              > > HTTPConnection con = new HTTPConnection("localhost",7001);
              > > HTTPResponse rsp;
              > > byte data[];
              > >
              > > if ((i % 10000) == 0) {
              > > log("\nGET Request "+i+" to "+ url + (debug ? "?debug=true" :
              > > ""));
              > > }
              > >
              > > requestStartTime = System.currentTimeMillis();
              > >
              > > rsp = con.Get("/mcumanager" + (debug ? "?debug=true" : ""));
              > >
              > > requestTime = System.currentTimeMillis() - requestStartTime;
              > >
              > > responseStartTime = System.currentTimeMillis();
              > >
              > > if (rsp.getStatusCode() >= 300) {
              > > log("Received Error: "+rsp.getReasonLine());
              > > log(new String(rsp.getData()));
              > > }
              > > else
              > > data = rsp.getData();
              > >
              > > responseTime = System.currentTimeMillis() - responseStartTime;
              > >
              > > totalRequestTime += requestTime;
              > > totalResponseTime += responseTime;
              > >
              > > if ((i % 10000) == 0) {
              > > log("GET Response "+i+": "+rsp);
              > > }
              > >
              > > if ((i % 100) == 0) {
              > > log ("Avg request time :
              > > "+((float)totalRequestTime/(float)i)+"ms");
              > > log ("Avg response time :
              > > "+((float)totalResponseTime/(float)i)+"ms");
              > > }
              > > }
              > > }
              > > catch (IOException ioe) {
              > > log(ioe.toString());
              > > ioe.printStackTrace();
              > > }
              > > catch (ModuleException me) {
              > > log("Error handling request: " + me.getMessage());
              > > me.printStackTrace();
              > > }
              > > }
              > >
              > >
              > >
              > >
              > >
              >
              >
              

  • 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.

  • Memory leak with CGImageSourceCreateThumbnailAtIndex

    After creating a thumbnail with CGImageSourceCreateThumbnailAtIndex, CGImageRelease doesn't seem to work!? I am rendering full-size thumbnails of PDF pages, and this just leaks memory:
    void memLeakTest(CFStringRef sourcePath) {
    printf("Running memLeakTest...
    CFURLRef url = CFURLCreateWithString(NULL, sourcePath, NULL);
    CGImageSourceRef imageSource = CGImageSourceCreateWithURL(url, NULL);
    CFStringRef keys[3];
    CFTypeRef values[3];
    int n=0;
    keys[n] = kCGImageSourceCreateThumbnailFromImageAlways;
    values[n++] = kCFBooleanTrue; //If I set this to false, there is no leak, but I need the thumbnails
    keys[n] = kCGImageSourceCreateThumbnailWithTransform;
    values[n++] = kCFBooleanTrue;
    keys[n] = kCGImageSourceShouldCache;
    values[n++] = kCFBooleanFalse;
    CFDictionaryRef options;
    options = CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys, values, n, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    CGImageRef image = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options);
    CFRelease( imageSource );
    CGImageRelease( image ); //Doesn't seem to have any effect. Memory continues to balloon.
    CFRelease( url );
    int main (int argc, const char * argv[]) {
    CFStringRef pathUrl = CFSTR("file:/path/to/a/big.pdf");
    while( true ) {
    memLeakTest( pathUrl );
    if( n < maxPages ) sleep(5); //Wait 5 seconds
    return 0;

    I was able to fix the memory leak using the following code:
    void memLeakTest(CFStringRef sourcePath) {
    printf("Running memLeakTest...
    CFURLRef url = CFURLCreateWithString(NULL, sourcePath, NULL);
    CFStringRef keys[10];
    CFTypeRef values[10];
    int n=0;
    //keys[n] = kCGImageSourceCreateThumbnailFromImageIfAbsent;
    //values[n++] = kCFBooleanTrue;
    keys[n] = kCGImageSourceCreateThumbnailFromImageAlways;
    values[n++] = kCFBooleanTrue;
    keys[n] = kCGImageSourceCreateThumbnailWithTransform;
    values[n++] = kCFBooleanTrue;
    keys[n] = kCGImageSourceShouldCache;
    values[n++] = kCFBooleanFalse;
    CFDictionaryRef options;
    options = CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys, values, n,
    &kCFTypeDictionaryKeyCallBacks,
    &kCFTypeDictionaryValueCallBacks);
    //CGImageSourceRef imageSource = CGImageSourceCreateWithURL(url, options);
    NSImage* imageFile = [[NSImage alloc] initByReferencingURL: (NSURL *)url];
    NSData * data = [imageFile TIFFRepresentation];
    CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)data, options);
    CGImageRef image = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options);
    CFRelease( image );
    CFRelease( imageSource );
    [imageFile release];
    CFRelease( options );
    CFRelease( url );
    There are a number of different graphics APIs you could use. I'm no expert in any of them, so I used the simple ones. The above code requires both Objective-C and an autorelease pool, but I'm sure you could use different functions to remove those requirements.

  • Memory Leak with 10.6.4

    This is very unusual for my Mab Desktops to do, but all I can figure is that there is a memory leak in the latest update 10.6.4 and that it is effecting everything.
    I ran a few apps on Friday night, closed then down but left the computer running. This morning, I tried the same apps and they would'nt load. I had to restart the computer to get them to work. The same thing happened on Thursday. I've fixed permissions so I can rule that out, unless of course it's the RAM it's self but I've ran tests on that and the software says that it's ok.
    Any suggestions would be appreciated on this subject.

    Can you open them, close them, and then immediately reopen them?
    Are they crashing or just bouncing in the Dock and never opening?
    Open Console and scroll down the log list and look for Diagnostic Reports. See if there are any logs related to the apps or the times the programs didn't open. There are a few sections with Diagnostic Reports. If they full up crash, there should be something under CrashReporter.

  • Memory leak with CursoredStream

    I want, first, to write a large collection of data in a file, and second, remove all these data.
    I use CursoredStream to manage them.
    I first use mark() method before iterate throw values with
    while (hasMoreElements()) { nextElement(); }
    loop, and second use reset() method to move back to first row before iterate again.
    I can only use releasePrevious() method in the second iteration to avoid memory leak. But the first iteration creates objects that are not released.
    If I use this method in the first iteration, I can't iterate the second times.
    Is it a bug?
    Is there a way to destroy all the created objects?

    Once you call releasePrevious() those objects are released and can only be accessed from a new query.
    What is the IdentityMap type you have set in your project for the class you are reading and the related classes, if the class has no reference to it (from other classes) you will want to use no-identity map. If there are references then you will want to use WeakIdentityMap.
    The second time you iterate through the Cursor you will be retrieving the same instance of objects as the first time, no extra memory will be used.
    --Gordon

  • Memory leak with variant/OCX

    I'm trying to get images from an IP webcam thanks to an ActiveX and process them with IMAQ.
    This ActiveX needs a variant to put chars from the image. It seems to work fine, (nearly 'in real-time') when I convert a string into a variant. Nevertheless, I have memory leak, if I put this sub-VI into a while loop.
    So, rather than using a string conversion, I've tried to use a Uchar array conversion. It also seems to work but it is really slow and in this case I don't have any leak of memory !
    I'm likely misunderstand the memory managment of Labview.
    Thank you very much for your help.

    Sorry for the VIs I've sent.
    Here are simplified VIs, with comments that illustrate the problem.
    I hope this will bring you clearer informations.
    Olivier M.
    Attachments:
    test_snap.vi ‏57 KB
    InitAxis.vi ‏36 KB
    SnapAxis.vi ‏38 KB

  • Memory leak with fieldpoint and labview

    I have an application which is showing an issue of a memory leak.  The application does several things, but the part that seems to be causing the trouble is related to use of Fieldpoint VIs.  The application reads individual AI channels on a Fieldpoint AI-110 (10 channels, where the set of channels is measured once per second)  I have attached the code related to this.  The memory leak is quite large (~1.5GB in 24 hours of operation).
    I am using LabView 7.1, and Fieldpoint 4.1.  The parent application which uses the attached code is a stand-alone application.  The operating system is Windows 2000.  Fieldpoint communication occurs over a RS-232 link.
    Thanks in advance,
    Andy
    Attachments:
    FPAI100_meas_voltage.vi ‏62 KB

    Hi Andy,
    I did not see anything fundamentally wrong with what you wrote, but there were
    a few things that I think could be used to be changed.  However, there
    were a few things that I did modify that might make a bit of a
    difference.  In your application you were using sequences and a bunch of
    local variables.  Since LabVIEW is based upon data flow, you can control
    the sequence of execution by making data dependencies and simply wiring one
    thing to the next.  By simply using LabVIEW the way it is meant to run I
    was able to completely remove the sequence structure and also eliminate the use
    of all of the local variables, all while having the exact same execution order. 
    It could be that the local variables were causing the memory leak that you
    noticed, but I really doubt they could be the cause of such a large leak. 
    I really think there is probably something else going on in the application
    because from what I saw from this bit of code there really is no way that it
    would have such large problems.  Users use the FP commands daily without
    any problems, so most likely these are not the root of the problem.
    Go ahead and try the modified code and see if you can implement similar local
    and global variable reducing techniques throughout your application. 
    Hopefully that will help reduce some of the memory leaks you are seeing. 
    Typically the largest cause of an apparent memory leak really occurs from
    building an array within a loop, so make sure you don't have any situations
    where that occurs in your code either.
    Regards,
    Otis
    Training and Certification
    Product Support Engineer
    National Instruments
    Attachments:
    724727-FPAI100_meas_voltage.vi ‏56 KB

  • Memory leak with File Write.vi

    Hi All,
    I am trying to save a big data cluster, which includes images, into a data log file. The vis I use are: New File.vi, Write File.vi, Close File.vi.
    The problem is Write File.vi has memory leak  when the data cluster includes images .
    Anyone sees similar case?  Any solution?
    Thanks.
    Aiqiu

    Aiqiu,
    I am glad you found out about flattening your image to a string.  I was about to post and say that you probably didn't want to save the IMAQ image reference to a file, because after you closed the image in memory, there wouldn't be anything for the IMAQ image reference to point to.  You are correct to flatten the image to a string.  Below is a link to a document which discusses doing this to communicate over datasocket, but the processes of flattening the image to a string is the same regardless of whether or not you are sending the image across a datasocket connection or saving to a file.
    Transfering Images with DataSocket
    As for the memory leak.  I am pretty sure that if you passed all of the IMAQ Image references created in the "Image Init Buffer.vi" subVI and then closed each reference individually, that the memory leak would probably go away.
    Lorne Hengst
    Application Engineer
    National Instruments

Maybe you are looking for