Memory Leak (may be) in Java 2D

Hi,
I am using a Java in an application that continuously reads data from a source and draws them on the screen. Everything runs fine as long as I stick to basic lines for drawing the graphs and it does not matter how many windows of the application is open. As soon as I start using dashed lines using BasicStroke - it starts consuming memory at a ridiculous rate (goes from 20M to 100M in about 20 seconds). Any idea where this leak might be coming from and how to fix this ? I have tried using dispose () all over the place but has not worked so far. Even System.gc() everytime in the paintComponent() of the the JPanel doing all the painting does not seem to do much good.
Thanks in advance to anyone who replies.
-Hassan.

Here is a more concrete example of what I am talking about - try running the following example with and without the g2.setStroke() line in method NewPanel.paintComponent() commented out and look at the memory usage and speed:
import java.io.*;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.io.*;
import java.util.*;
public class TestMU extends JFrame {
public TestMU(){
     super();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
          System.exit(0);
     getContentPane().add(new NewPanel());
public static void main (String argv []){
     TestMU gu = new TestMU();
gu.setSize(new Dimension(550,700));
gu.setVisible(true);
class NewPanel extends JPanel{
public NewPanel(){
     super();
public void paintComponent(Graphics g){
     super.paintComponent(g);
     int i;
     float dash1[] = {1.0f};
     BasicStroke bs = new BasicStroke(.5f, BasicStroke.CAP_BUTT,
                         BasicStroke.JOIN_MITER, 1f, dash1, 0.0f);
     Graphics2D g2 = (Graphics2D)g;
     // This line right here!!!
// Try it with and without the g2.setStroke() line
     g2.setStroke(bs);
     for (i=1;i<20000;i++){
     g2.drawLine(20,30,i,30);
     if (i%100 == 0) System.err.println(i);
Memory usage goes from around 19 MB to 60 MB and repainting speed goes from about 2 seconds to a minute (or more) when the line is uncommented.
Does anyone know what additional stuff java might be storing and doing that's causing the increase in memory usage and such drastic reduction in speed ?
-Hassan

Similar Messages

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

  • 1.6.0_10 and 11, Memory leak returning variables from Java to JavaScript

    Environment: Windows XP SP2, IE7, JScript 5.7, JRE 1.6.0_11-b03 and 1.6.0_10
    Memory allocated in Java and returned as a JavaScript variable value is not garbage collected in Java when the JavaScript variable is re-used.
    In the following simplified example, a populated HashMap is returned from the applet test1 method to the JavaScript variable hash1.
    The JavaScript variable hash1 is re-used on the next iteration so I would expect it should be marked for garbage collection.
    In 1.6.0_7 and previous releases, the memory associated with this Java HashMap is freed implicitly.
    In 1.6.0_10 and 1.6.0_11 the HashMap memory is never freed.
    Is this is what we should expect, a feature of the significant LiveConnect changes that were part of 1.6.0_10?
    Do we need to rewrite our code to call new Java methods from JavaScript explicitly freeing the memory, in this example calling the freeMem method?
    Has anybody else experienced this problem since 1.6.0_10?
    Thanks
    Rob
    Example code ...
    TestRLApplet.java
    import java.applet.Applet;
    import java.util.HashMap;
    public class TestRLApplet extends Applet
    private HashMap hash1;
    public TestRLApplet()
    public void init()
    public HashMap test1()
    hash1 = new HashMap();
    for (int i = 0; i <10; i++) {
    hash1.put(Integer.toString(i),Integer.toString(i));
    return (hash1);
    public void freeMem() {
    hash1.clear();
    hash1 = null;
    TestClient.htm
    <HEAD>
    <TITLE></TITLE>
    <SCRIPT LANGUAGE="javascript">
    function window_onload()
    var hash1;
    testAppplet = document.TestRLApplet;
    for (cnt=0; cnt < 1000; cnt++)
    hash1= testAppplet.test1();
    </SCRIPT>
    </HEAD>
    <object
    classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 1 HEIGHT = 1 NAME = "TestRLApplet" >
    <PARAM NAME = CODE VALUE = "TestRLApplet.class" >
    <PARAM NAME = ARCHIVE VALUE = "../applets/TestRLApplet.jar" >
    <PARAM NAME = NAME VALUE = "TestRLApplet" >
    <PARAM NAME = MAYSCRIPT VALUE = true >
    <param name = "type" value = "application/x-java-applet;version=1.6">
    <param name = "scriptable" value = "false">
    </object>
    <BODY LANGUAGE=javascript onload="return window_onload()" leftMargin=40 id=body >
    </BODY>
    </HTML>
    Java Console
    Java Plug-in 1.6.0_10
    Using JRE version 1.6.0_10 Java HotSpot(TM) Client VM
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    Memory: 5,056K Free: 2,551K (50%) ... completed.
    Memory: 7,996K Free: 3,499K (43%) ... completed.
    Memory: 7,996K Free: 1,038K (12%) ... completed.
    Memory: 13,180K Free: 3,745K (28%) ... completed.
    Memory: 22,844K Free: 5,614K (24%) ... completed.
    Memory: 37,984K Free: 15,009K (39%) ... completed.
    Memory: 37,984K Free: 13,069K (34%) ... completed.
    Memory: 37,984K Free: 6,125K (16%) ... completed.
    Memory: 65,088K Free: 25,107K (38%) ... completed.
    Memory: 65,088K Free: 21,201K (32%) ... completed.
    Memory: 65,088K Free: 13,381K (20%) ... completed.
    Memory: 65,088K Free: 7,967K (12%) ... completed.
    Memory: 65,088K Free: 5,013K (7%) ... completed.
    Memory: 65,088K Free: 414K (0%) ... completed.

    What are you missing?
    I inherited this app and signing the third party jars is how it was setup, I was wondering the same thing too, why was it necessary to sign the third party jars?
    The applet runs in either JRE 1.6.0_13 or JRE 1.6.0_27 depending on the other Java apps the user uses. JRE 1.6.0_13 does not have the mixed code security (so it is like is disable), but JRE 1.6.0_27 does have the mixed code security and the applet will not launch with mixed code security enable, so we have to disable it. With all the hacking going on in the last two years, is important to improve security; so this is a must.
    Yes, I always clear up the cache.
    Any idea on how to resolve this problem?

  • 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 leak with jsp and beans

    The application we have created has one particular page that is designed to stay up in the browser and refresh with new information from database queries once every 60 seconds. Running with Tomcat3.2.1 and IE5.5
    The problem is that the memory usage of java.exe continues to grow until the machine crashes from out of memory. It does take more than 24 hours to crash.
    Things I have tried to do to track down the problem or eliminate the problem.
    - I have explicitly set the scope of the beans to "page"
    - I have watched the DatabaseAccess.class (the beans are all extended from this class) and put in code to watch how many instantiations of the class are made and subsequently garbage collected. This appears to be where the memory leak may reside - hundreds of instantiations from some other source than the page I am displaying.
    - the top frame makes database queries for security and display of a menu system dependant upon security clearance. It does not set any time for refresh (refresh == 0). Nor does it explicitly set a scope for the beans.
    - I have run a different jsp engine to see if this was directly related to Tomcat - same problem with resin2.0.0
    The main jsp page that is in the bottom section of the page has the following code:
    ** only the relevant lines are included here
    <%@ include file="../../common.jsp" %>
    <%
         refresh=60;
    %>
    <head>
    <%@ include file="../../meta_head.jsp" %>
    </head>
    <body bgcolor="#FFFFFF" text="#003399" link="#660099" vlink="#990099" alink="#006666" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <%@ include file="../../access.jsp" %>
    <%@ include file="../../page_title.jsp" %>
    <jsp:useBean id="Line" class="jsp.Line" scope="page" />
    <jsp:useBean id="Machine" class="jsp.Machine" scope="page"/>
    <jsp:useBean id="Alarm_log" class="jsp.Alarm_log" scope="page"/>
    contents of meta_head.jsp
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <META HTTP-EQUIV= "expires" content = "0">
    <META HTTP-EQUIV="Pragma" CONTENT="no_cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache" forua="true">
    <META NAME="robots" content="NOINDEX,NOFOLLOW">
    <%
    if (refresh > 0)
    %>
    <meta http-equiv="Refresh" content="<%= refresh %>">
    <%
    If anyone has some suggestions on how to trap this memory leak, it would be terrific. Or, some other things to try to stop the instantiation of the DatabaseAccess object (perhaps setting the scope of the beans in the header to "session" or "application"?).
    Thanks in advance.
    Roberta

    jsp:useBean tags scope declaration :
    page = Create a new instance on each load.
    session = Load instance from the session, if not there, create one
    application = Load instance from the ServletContext, if not there, create one.
    Not sure how you are populating the data variables, but make sure you are closing all ResultSet, (Prepared)Statement, and Connection objects.

  • Memory leak using GWT 1.4 and JDK 1.5

    We are running the following:
    OS : Solaris 5.10
    WebLogic version: 10.0
    JDK : Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
    Java HotSpot(TM) Server VM (build 1.5.0_14-b03, mixed mode)
    GWT : 1.4
    Oracle : 10g
    We have found memory leak with the above configuration.
    After running 1 session we are facing memory leak. The used Java heap is 4% higher than the one used after we conduct
    our memory tests for 1 user.
    Similarly, after running 5 concurrent sessions we are also facing memory leak where Java heap memory is utilised more
    by about 4%.
    I have used JRockit JDK 1.5 for figuring out memory leak. I have not found a memory leak in any of the modules
    developed by us.
    The memory leak issue is we think concerned with the version of JDK, Weblogic, Sun OS.
    Can somebody please suggest whether we can use the version as mentioned above?
    Any help on this front will be appreciated.

    gc log:
    #log information
    JAVA_OPTS="$JAVA_OPTS -verbose:gc "
    JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails "
    JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps "
    JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC "
    JAVA_OPTS="$JAVA_OPTS -Xloggc:/path/to/gclog`date +%Y.%m.%d-%H:%M:%S`.log "Check sun papers for garbage collecting tips.
    >
    Is there any other way we can detect memory leak?
    >
    You have to profile your Application Server like you did with your own code.
    regards
    slowfly

  • JRE issues - Memory leak

    We have a memory leak in an enterprise java application.
    I need a way to reset the JVM. When i start the program, and clients connect to it, the memory keeps going up. as a quick fix we figured we could stop that program and restart it (giving us time to find the leak).
    The memory starts where it left off. ??? any ideas how to reset the mem usage? clear the heap?
    Please helpp... thanks...

    Thanks for the response.
    do you know the different between running the JVM on a 64-bit machine vs. on 32-bit machine? both windows.

  • How can memory leaks occur?

    Hi,
    I was just wondering how a memory leak can occur in Java. The garbage collector is supposed to free up all unused variables, so under what circumstances can it happen?

    This is not technically a "memory leak". I've seen
    this called "loitering objects", which conjures upa
    vivid picture: objects hanging around with nothingto
    do...I think it's the classic java memory leak. A bug in
    a program that prevents the freeing up of memory that
    it no longer needs.Yes, but it's not what is traditionally termed a memory leak.
    A real memory leak is memory that's claimed by the program but no longer accessible to the program for freeing up.
    That can in Java (where what we call a program isn't a complete program but runs inside a virtual machine which handles memory allocation and deallocation) only happen if there's a flaw in the JVM itself which causes errors in memory deallocation (so most likely a flaw in the garbage collector).
    In Java the objects you create are always out there somewhere where something can reach them so as to prevent them from being available to the garbage collector.
    Different cause, same effect in that in both cases memory isn't getting freed for reuse.

  • PrinterJob and Memory Leak

    I have encounter a serious memory leak when printing in Java. When the following code is compiled into a 'jar' (1.4.x and 1.5.x) and run, the Print process consumes roughly 4 Mb and never gives it back. Does anybody have a solution for recovering the lost memory?
    import java.awt.*;
    import java.awt.print.*;
    public class BasicPrint extends JComponent implements Printable {
    public int print(Graphics g, PageFormat pf, int pageIndex) {
    if (pageIndex > 0) {
    return Printable.NO_SUCH_PAGE;
    Graphics2D g2d = (Graphics2D)g;
    g2d.translate(pf.getImageableX(), pf.getImageableY());
    g2d.draw3DRect(20,50,100,50,true)
    return Printable.PAGE_EXISTS;
    public static void main(String[] args) {
    PrinterJob pjob = PrinterJob.getPrinterJob();
    PageFormat pf = pjob.defaultPage();
    pjob.setPrintable(new BasicPrint(), pf);
    try {
    pjob.print();
    } catch (PrinterException e) {
    //// You will need to set up a break point after this to examine the consequences on
    //// Memory
    }

    The setting is an option that's used on the java command, for instance:
    java -XX:MaxHeapFreeRatio=70 <yourClassName>See the results returned by the search on the option name:
    http://www.google.com/search?q=XX:MaxHeapFreeRatio

  • 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

  • What is memory leak in Java context?

    I am looking for a precise definition here...

    If you are looking for HOW a memory leak can show up in java, here are a few examples:
    A stack implemented on an array can have a memory leak if the object's position in the array isn't set to null after the object is popped off the stack (I think I first saw that in "effective java", by joshua bloch, if you want to look more into that).
    Another way: interning strings to the jvm can cause a memory leak, because once a string is interned, it is stuck there forever, even if all other references to the string are gone, and the string will never again be used.
    Furthermore, any flyweight concept that doesn't have a strategy for pruning away unused object (objects with 0 external remaining references) will be a memory leak of a sort.
    Hash maps are another place you can run into this problem. They may hold the only reference to both objects of a pair, and hence, since the key exists nowhere else, the pair is basically useless, but the map does prevent them from being garbage collected.
    What's the common link? The all have to do with some data structure or another maintaining obsolete references to objects. Since objects can't go out of scope if they are stored in a data structure that doesn't go out of scope, they cannot be garbage collected.
    - Adam

  • Memory Leak Java Plugin with Swing Applet

    Hi
    I experience the following problem and desperately need help on this. The Java Plugin (I use Version 1.3.1_02) seems to have a problem in printing Swing Applets.
    The problem can easily be reproduced (at least with NT):
    1) Start Internet Explorer or Netscape (I used 5.5/4.07)
    2) Launch the following demo swing applet
    http://java.sun.com/products/plugin/1.3.1_01a/demos/jfc/SwingSet2/SwingSet2Plugin.html
    3) Print the applet and observe (using task manager) the memory used by the browser process (the memory used by the process will increase every time you hit the print button but never decrease unless you shut down the browser)
    4) Print a couple of times (you may want to pause your print queue) and you will be able to crash your computer
    This seems to be the same bug reported with 4638742. However it says "in progress" for quite some time and I was wondering if some genious might know a work around for this.
    Cheers

    You might want to read an article about memory leaks in Java:
    http://www-106.ibm.com/developerworks/library/j-leaks/

  • Can Java program cause memory leak?

    Can Java program cause memory leak or memory crash? I don't mean any memory overflow related exceptions. I mean something like core dump in UNIX or error reports in Windows XP.
    If it can really happen, in what circumstances? I raise such a question because our J2EE based system had really caused memory leak in Windows XP systems, but so far we still fail to troubleshoot the problem.

    Your code may leak memory. There are many, many, many reasons this could be. All of them represent bugs in your code.
    You should get a profiler to identify the problem spots of your code.
    You spoke of a memory crash as well. The VM may crash with some bug in the VM, or a bug in native code but that is not relevent to your problem. A memory leak is a problem in your code.

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

Maybe you are looking for

  • How to add two list in one frame using REUSE_ALV_LIST_DISPLAY

    Hi, I want to display two list in single output by calling FM 'REUSE_ALV_LIST_DISPLAY' twice. I saw one topic posted by Arunava Das as 'ALV Problem' but didn't get the steps to do that. Here is his way of doing that "What I have done is gone for the

  • Z1 compact update 14.4.A.0.157 fails

    Hello, a couple of days ago i bought a Xperia Z1 Compact. From the beginning it told me there was a firmware update which fails to install. I did some research and apparently I'm note alone with my problem but none of the information I could find hel

  • Using apex url to link to a page in another application

    hi all. i have 5 applications based on same schema in a single workspace. now i intent to have a single page with 5 button from where i will call all those 5 applications' home pages. i used following syntax for URL Target on a button to check it but

  • Can't launch photoshop CC 2014

    Just got creative cloud . I Can't open Photoshop. I already uninstall and reinstall it. Still doesn't work. In my "dashboard" of creative cloud I see that LR is active,,, but not photoshop. any ideas? Thanks

  • I just want ti print a card I made on my computer....

    This is our new printer...I can't get it to just print a card I made on the computer...all the printer window (on the printer) says is "Copy" "Fax" and "Scan"   but it won't print just my computer-made card...How can I get it to print that?