Memory Leak in a multi threaded Swing application  (ImageIcon)

When I profile my swing application with netbeans 5.5 , I notice that after each periodically tidy up my image container (add,remove IconImage objects to a hashmap or arraylist), there gather by and by surviving objects. This leads to run out of memory after a while. Is there any other way to avoid this effect?
Any ideas about "The JVM is notorious for caching images."
please help..
what I have made briefly:
1.) Read the binary stream from the db :
rs=stmt.executeQuery(query);
if(rs.next()){
    int len=rs.getInt(2);
    byte [] b=new byte[len];
    InputStream in = rs.getBinaryStream(3);
    try {
            in.read(b);
            in.close();
            img=Toolkit.getDefaultToolkit().createImage(b);
     } catch (IOException e) {
            e.printStackTrace();
stmt.close();
rs.close();2.) hold the icon as field :
this.icon =  new ImageIcon(img);3.) After a while I remove the object from my collection and on the
overridden method finalize() I also call the flush() method.
if(this.icon != null){
            this.icon.getImage().flush();
            this.icon = null;
}The surviving objects still increase?! On the page of SUN they
submitted a bug. But this is set on closed/fixed.
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4014323)
What am I doing wrong? I also use the byte[] constructor on creating the icon and
my java version is 1.5.0_10.

If in your JFrame u have placed your image, before invoke the dispose()
method put explicitly the image pointer to null and deregister all listener
you have added to any componentI implemented your suggest and after starting a long time test, in one hour there gathered aprox. 500 surviving generations. I attach a snapshot and the java file ( http://www.box.net/public/eqznamrazd ). The used heap size swings between 3MB and 5MB. I guess this wont kill so quickly the application but anyway there is something wrong!
Even properly closed streams, database connections etc.. Really despairing. Could one take a look to the java source?
some snippets bellow:
private class MyImageIcon extends ImageIcon {
        public MyImageIcon(Image img){
            super(img);
        public void removeImage(Image anImage){
            tracker.removeImage(anImage);
private class DetailDialog extends javax.swing.JFrame {
        private String personnr;
        private MyImageIcon icon;
        public DetailDialog(String personnr,MyImageIcon icon){
            this.personnr = personnr;
            this.icon = icon;
        public void dispose() {
            if(icon != null){
                icon.removeImage(icon.getImage());
                icon.getImage().flush();
                icon = null;
            super.dispose();
private class Person extends Object {
        private MyImageIcon icon;
        private String number;
        private DetailDialog detailDialog;
        protected void destroy() {
            if(icon!=null){
                icon.removeImage(icon.getImage());
                icon.getImage().flush();
                icon = null;
            if(detailDialog!=null){
                detailDialog.dispose();
private Image LoadImageFromDB(String personnr){
        Image img = null;
        String filename = personnr + ".jpg";
        Connection con = getMysqlConnection();
        Statement stmt;
        ResultSet rs;
        try {
            stmt = con.createStatement();
            String query = "select * from personImage where image='"+filename+"'";
            rs=stmt.executeQuery(query);
            if(rs.next()){
                int len=rs.getInt(2);
                byte [] b=new byte[len];
                InputStream in = rs.getBinaryStream(3);
                try {
                    in.read(b);
                    in.close();
                    img =
                            java.awt.Toolkit.getDefaultToolkit().createImage(b);
                } catch (IOException e) {
                    e.printStackTrace();
            rs.close();
            rs = null;
            stmt.close();
            stmt = null;
            con.close();
            con = null;
        } catch (SQLException e) {
            e.printStackTrace();
        return img;
public void random(){
        java.sql.ResultSet rs = null;
        java.sql.Statement stmt=null;
        java.sql.Connection con = getSybaseConnection();
        try {
            try {
                stmt = con.createStatement();
                rs = stmt.executeQuery(randomquery);
                while(rs.next()){
                    Person person = new Person();
                    person.number = rs.getString("PersonNr");
                    Image img = LoadImageFromDB(person.number);
                    if(img !=null){
                        MyImageIcon ico = new MyImageIcon(img);
                        person.icon = ico;
                    person.detailDialog = new
                            DetailDialog(person.number,person.icon);
                    personList.add(person);
                    System.out.println("Container size: " +
                            personList.size());
                    counter++;
                if(counter%20 == 0){
                    for(Person p : personList){
                        p.destroy();
                    personList.clear();
                    System.gc();//no need, but I force for this example
                    System.out.println("Container cleared, size: " +
                            personList.size());
            } catch (SQLException ex) {
                ex.printStackTrace();
            }finally{
                if(rs != null){
                    rs.close();
                }if(stmt != null){
                    stmt.close();
                }if(con != null){
                    con.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
    }

Similar Messages

  • Easy to produce - Memory Leak in JVM Using thread

    I was just debugging the problem with our server and got this error (not from the original code, I reproduced it with small code)
    at java.lang.Thread.run(Unknown Source)
    java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Unknown Source)
    at SomeObject.resursiveThreadGeneratorMethod(ThreadRecursionLeak.java:12
    at ClientThread.run(ThreadRecursionLeak.java:27)
    it is just a simple program generating thread recursively with a lock on an object
    import java.lang.Runnable;
    import java.lang.Thread;
    //     <<Objec/Monitor Class>>
         class SomeObject{
              public synchronized void resursiveThreadGeneratorMethod(int threadNumber, int k){
                   if(k<=0)
                        return;
                   else{
                        System.out.println("Thread: "+threadNumber + "call number: "+k);
                        Thread thread=new Thread(new ClientThread(this));
                        thread.start();
                        resursiveThreadGeneratorMethod(threadNumber,k-1);
    //     <<Thread Class>>
         class ClientThread implements Runnable{
              SomeObject someObject=null;
              public static int threadNumber;
              public ClientThread(SomeObject someObject){
                   this.someObject=someObject;
                   threadNumber++;
              public void run(){
                   someObject.resursiveThreadGeneratorMethod(this.threadNumber,10);
    //     <<Driver Class>>
         public class ThreadRecursionLeak{
              public static void main(String [] args){
                   SomeObject someObject=new SomeObject();
                   Thread thread=new Thread(new ClientThread(someObject));
                   thread.start();
    is there any way I can monitor JVM memory status (programatically), kill those threads leading to memory leak and send notification to the system admin.
    We run JVM 1.4 on the server and need to address this issue as we do not have control over the code that can be submitted to the server, we just do some checks and then let it run on the servers.
    Our main requirement is to keep JVM alive and kill all those code and report them.
    Message was edited by:
    rajanikant_malviya

    You can monitor the JVM with the
    [url=http://java.sun.com/j2se/1.4.2/docs/guide/jvmpi/i
    ndex.html]JVMPI if you're using the Sun JVM.This is native code that basically gets
    notified anytime the JVM does something
    interesting.
    However, you're going to have a very difficult time
    catching code that does what the code you show does.
    I'm not sure I understand your environment - you
    allow people to submit code and you run it? Are you
    running it in the same JVM as your server? That
    seems like a huge issue. A simple System.exit()
    code will take down your server.
    Let us know some more details.
    We are actually having a portal through witch users can submit their code, witch are basically utility codes for different operations teams.
    we then provide a way to schedule them.
    At the background, we are having 6 (Win) servers where at each server we are having 20 to 25 users on different ports (managed by our application) running there own JVMs. When a schedule is met we just invoke a servlet (on any free port) and pass code id (stored in DB). And this servlet is responsible for compilation and exicution of the code (We just use Runtime to fork this new process).
    I don't know, but is there any way through witch I can monitor this process and restrict to generate threads recursively???

  • Nasty memory leak using sockets inside threads

    In short, any time I create or use a socket inside a worker thread, that Thread object instance will never be garbage collected. The socket does not need to be connected or bound, it doesn't matter whether I close the socket or not, and it doesn't matter whether I create the Socket object inside the thread or not. As I said, it's nasty.
    I initially encountered this memory leak using httpclient (which creates a worker thread for every connect() call), but it is very easy to reproduce with a small amount of stand-alone code. I'm running this test on Windows, and I encounter this memory leak using the latest 1.5 and 1.6 JDK's. I'm using the NetBeans 5.5 profiler to verify which objects are not being freed.
    Here's how to reproduce it with an unbound socket created inside a worker thread:
    public class Test {
         public static class TestRun extends Thread {
              public void run() {
                   new Socket();
         public static void main(String[] strArgs) throws Exception {
              for(;;) {
                   (new TestRun()).start();
                   Thread.sleep(10);
    }Here's how to reproduce it with a socket created outside the thread and used inside the worker thread:
    public class Test {
         public static class TestRun extends Thread {
              Socket s;
              public TestRun(Socket s) { this.s = s; }
              public void run() {
                   try {
                        s.bind(new InetSocketAddress(0));
                        s.close();
                   } catch(Exception e) {}
         public static void main(String[] strArgs) throws Exception {
              for(;;) {
                   (new TestRun(new Socket())).start();
                   Thread.sleep(10);
    }Here's how to reproduce it implementing Runnable instead of extending Thread:
    public class Test {
         public static class TestRun implements Runnable {
              public void run() {
                   Socket s = new Socket();
                   try { s.close(); } catch(Exception e) {}
         public static void main(String[] strArgs) throws Exception {
              for(;;) {
                   (new Thread(new TestRun())).start();
                   Thread.sleep(10);
    }I've played with this a lot, and no matter what I do the Thread instance leaks if I create/use a socket inside it. The Socket instance gets cleaned up properly, as well as the TestRun instance when it's implementing Runnable, but the Thread instance never gets cleaned up. I can't see anything that would be holding a reference to it, so I can only imagine it's a problem with the JVM.
    Please let me know if you can help me out with this,
    Sean

    Find out what is being leaked. In the sample programs, add something like this:
        static int loop_count;
            while (true) {
                if (++count >= 1000) {
              System.gc();
              Thread.sleep(500); // In case gc is async
              System.gc();
              Thread.sleep(500);
              System.exit(0);
            }Then run with java -Xrunhprof:heap=sites YourProgram
    At program exit you get the file java.hprof.txt which contains something like this towards the end of the file:
              percent          live          alloc'ed  stack class
    rank   self  accum     bytes objs     bytes  objs trace name
        1  0.47%  0.47%       736    5       736     5 300036 char[]
        2  0.39%  0.87%       616    3       616     3 300000 java.lang.Thread
        3  0.30%  1.17%       472    2       472     2 300011 java.lang.ThreadLocal$ThreadLocalMap$Entry[]
        4  0.27%  1.43%       416    2       416     2 300225 java.net.InetAddress$Cache$Type[]See, only three live Thread objects (the JVM allocates a few threads internally, plus there is the thread running main()). No leak there. Your application probably has some type of object that it's retaining. Look at "live bytes" and "live objs" to see where your memory is going. The "stack trace" column refers to the "TRACE nnnnn"'s earlier in the file, look at those to see where the leaked objects are allocated.
    Other quickies to track allocation:
    Print stats at program exit:
    java -Xaprof YourProgram
    If your JDK comes with the demo "heapViewer.dll" (or
    heapViewer.so or whatever dynamic libraries are called on your system):
    java -agentpath:"c:\Program Files\Java\jdk1.6.0\demo\jvmti\heapViewer\lib\heapViewer.dll" YourProgram
    Will print out statistics at program exit or when you hit Control-\ (Unix) or Control-Break (Windows).

  • Memory leak when creating new thread.

    Hi,
    Each time i create a thread, it causes 8 bytes memory leak. The testing code is as below and you can see mem usage increasing in Windows Task Manager. But if i don't call ::OCIEnvCreate(), no memory leak.
    Memory validator shows the following call stack information:
    ........largest allocation 8 bytes at .......
    =>OraOCIEI10.dll ss_mem_thread_attach
    =>OraOCIEI10.dll sscoresetserverflag
    =>OraOCIEI10.dll slzgetevar
    =>ntdll.dll LdrInitializeThunk
    Anyone knows what is goiing on?
    /Yue
    #include <stdio.h>
    #include <windows.h>
    #include <process.h>
    #include <oci.h>
    static OCIEnv *env;
    static unsigned int counter = 0;
    unsigned __stdcall ThreadFunc(void* pArg)
    counter++;
    printf( "In %uth thread...\n", counter );
    Sleep(100);
    _endthreadex( 0 );
    return 0;
    int main( int argc, const char* argv[] )
         sword rc = ::OCIEnvCreate(&env, OCI_DEFAULT, NULL, NULL, NULL, NULL, 0, NULL );
         for(;;)
              HANDLE hThread;
              unsigned threadID;
              // Create the second thread.
              hThread = (HANDLE)_beginthreadex( NULL, 0, &ThreadFunc, NULL, 0, &threadID );
              WaitForSingleObject( hThread, INFINITE );
              // Destroy the thread object.
              CloseHandle( hThread );
         return 0;
    }

    Hi,
    I'm not suprised.
    OCI offers the feature OCIThreadKey that allow you to store a pointer within a thread context (without using OCIThread, just using natives threads).
    So OCI needs to catch thread creation to be able to register storage for its OCIThread key value and be able, once the thread is finished to call a callback with the pointer value associated with the thread....

  • Multi-tier Swing Application

    Hi,
    I'm currently in the planning stages of an application that will use swing, be deployed on a Websphere Application Express V5 server, and access a postgresql database. The application will need to display/add/modify data as well as do complex calculations, validations, etc. All database requests need to be made from the application server rather than the client. I'm having trouble figuring out what approach to take. I'm reading up on Swing, but what do I need to use to handle the data. Ejb's are not supported on our application server. Should I use RMI, servlets, or javabeans or a combination. Is there anything else I should consider. Any help would be appreciated. Thank you.

    You seem determined to use Swing.
    I am not sure that it is necessarily a good idea. Yes Swing allows you to create a native look and feel, but what else is it giving you? If you want to do a lot of local processing such as a CAD program, then fair enough. But Swing also give you the security risk that people can view and change your Swing code as it will likely be on the client machines. This means you will have to consider how to protect passwords.
    A servlet could communicate with Swing but is more usually in communication with a browser. This seems a little more secure. You will be able to design forms similar to the sun forum and display data. Also because the code is on the server, you can update everyones code easily.
    However if this is your first big project, you should buy in some experience, as suggested previously.

  • Multi-threaded java application and deadlock down in Oracle library

    Hello,
    I was running our Java (JDK 1.6_14) application from Windows XP hitting an Oracle (10g) instance on Linux and came across a deadlock issue with two (of 10) threads. Below is the stacktraces (based on Java thread-dump at the command line). This code I've run 30-40 times with no problems of deadlocks.
    The Oracle library that we're using for our Java application is ojdbc14.jar and sdoapi.jar (for spatial).
    We create our Connection as follows (for each thread -- 10 of them):
    public class Worker implements Runnable
    private Connection _Conn;
    public Worker(...)
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    _Conn = DriverManager.getConnection(url, username, password);
    _Conn.setAutoCommit(false);
    The code that is already executing these same lines below was already executed by other threads (in their own instance of Worker). So this is very confusing.
    Any ideas? Version of the .jar files? Place how we're calling "DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());"?
    Thanks, Jim
    Found one Java-level deadlock:
    =============================
    "WORKER_1":
    waiting to lock monitor 0x02b50d8c (object 0x22e8af80, a oracle.jdbc.driver.T4CConnection),
    which is held by "WORKER_0"
    "WORKER_0":
    waiting to lock monitor 0x02b50d24 (object 0x22f6d258, a oracle.sql.StructDescriptor),
    which is held by "WORKER_1"
    Java stack information for the threads listed above:
    ===================================================
    "WORKER_1":
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3410)
    - waiting to lock <0x22e8af80> (a oracle.jdbc.driver.T4CConnection)
    at oracle.sql.StructDescriptor.initMetaData1_9_0(StructDescriptor.java:1516)
    - locked <0x22f6d258> (a oracle.sql.StructDescriptor)
    - locked <0x22eabd80> (a oracle.jdbc.driver.T4CConnection)
    at oracle.sql.StructDescriptor.initMetaData1(StructDescriptor.java:1408)
    at oracle.sql.StructDescriptor.isInstantiable(StructDescriptor.java:892)
    at oracle.sql.STRUCT.<init>(STRUCT.java:148)
    at oracle.spatial.geometry.JGeometry.store(JGeometry.java:2954)
    at oracle.spatial.geometry.JGeometry.store(JGeometry.java:3777)
    .......... <our package/class>
    "WORKER_0":
    at oracle.sql.StructDescriptor.initMetaData1_9_0(StructDescriptor.java:1494)
    - waiting to lock <0x22f6d258> (a oracle.sql.StructDescriptor)
    - locked <0x22e8af80> (a oracle.jdbc.driver.T4CConnection)
    at oracle.sql.StructDescriptor.initMetaData1(StructDescriptor.java:1408)
    at oracle.sql.StructDescriptor.isInstantiable(StructDescriptor.java:892)
    at oracle.sql.STRUCT.<init>(STRUCT.java:148)
    at oracle.spatial.geometry.JGeometry.store(JGeometry.java:2954)
    at oracle.spatial.geometry.JGeometry.store(JGeometry.java:3777)
    ..........<our package/class>
    Edited by: Jim Atharris on Aug 24, 2009 6:23 PM

    Thanks Toon for your reply.
    Yes each Worker (executing in their own thread) has their own instance of Connection as per the Constructor (shown in original post). That is why this is weird.
    I'll check the v$session when I get into work.
    Based on our code that I put in the original email, Connection is a non-static variable. We have a per Thread per instance of Worker of which that Worker instance has its own instance of Connection. So I'm wonder if the following needs to occur:
    Both of these lines (from original email) need to happen in the main thread as follows:
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    for (i=0;i<NUM_OF_WORKERS)
    _Conn = DriverManager.getConnection(url, username, password);
    new Worker(_Conn);
    Thanks,Jim

  • Multi-Threading Standalone Application as Backgroup OS Process

    Hi Fellas
    I have written a Standalone Server Application which when run in background (using the following command) doesnt run any of the Threads at all.
    ./scheduler &
    Whereas when this application when run in foreground i.e. without & (ampersand) at the end, it works fine.
    The application spawns configurable number of thread and all the threads periodically wait for job to be put in the job queue. One thread arbitrarily picks one job and runs it.
    Does someone know the mystery? I am supposed to run this on HP/UX where I am having this problem. Just tried on SunOS ... same behaviour here as well.
    Guyz help me asap as we are a day away from the deployment in production. I never thought about this.
    Thanks in Advance
    Saleem

    Hi Chuck
    Well the process without Threads is nothing. The process (application) kicks off Threads and then those Threads execute jobs and all.
    I am not sure whether this is caused by SIGHUP. I am not familiar much with these signals and all. Please help me understand this.
    Yes I tried 'nohup' as follows:
    nohup ./scheduler -vm cmd -env dev -d -t > screen_dump
    when this command gets executed, I open another telnet window and tail 'screen_dump' file. After issuing the command above, prompt is not available so it doesnt seem to me like a bckground application. So when I kill/close that terminal window, the screen_dump file starts growing for some unknown (to me) reason.
    I am definitely writing tons of stuff/traces to this 'screen_dump' file and the application waits for the user to key in commands like start, refresh, shutdown etc. Is this I/O blocking the whole application while in background?
    Thanks for your reply. I look forward to hear from you.
    Saleem

  • TestStand 2010 Memory Leak when calling sequence in New Thread or New Execution

    Version:  TestStand 4.5.0.310
    OS:  Windows XP
    Steps to reproduce:
    1) Unzip 2 attached sequences into this folder:  C:\New Thread Memory Leak
    2) Open "New Thread Memory Leak - Client" SEQ file in TestStand 2010
    3) Open Task Manager, click Processes tab, sort A-Z (important), and highlight the "SeqEdit.exe" process.  Note the memory useage.
    4) Be ready to click Terminate All in TestStand after you see the memory start jumping.
    5) Run the "New Thread Memory Leak - Client" sequence.
    6) After seeing the memory consumption increase rapidly in Task Manager, press Terminate All in TestStand.
    7) Right click the "While Loop - No Wait (New Thread)" step and set Run Mode » Skip
    8) Right click the "While Loop - No Wait (New Execution)" step and set Run Mode » Normal
    9) Repeat steps 3 through 6
    I've removed all steps from the While Loop to isolate the problem.  I've also tried the other methods you'll see in the ZIP file but all cause the memory leak (with the exception of the Message Popup).
    I have not installed the f1 patch, but none of the bug fixes listed appear to address this issue.  NI Applications Engineering has been able to reproduce the issue (with Windows 7) and is working on it in parallel.  That said, are we missing something??
    Any ideas?
    Certified LabVIEW Architect
    Wait for Flag / Set Flag
    Separate Views from Implementation for Strict Type Defs
    Solved!
    Go to Solution.
    Attachments:
    New Thread Memory Leak.zip ‏14 KB

    Good point Doug.  In this case parallel sequences are being launched at the beginning of the sequential process model, but I'll keep that in mind for later.  Take away:  be intentional about when to wait at the end of the sequence for threads to complete.
    Certified LabVIEW Architect
    Wait for Flag / Set Flag
    Separate Views from Implementation for Strict Type Defs

  • Oraclient9i.dll error in multi threaded delphi server application

    I created a multi threaded server application in delphi using oracle9i and indy server components. When I run my application, I am getting an error "oraclient9i.dll" error when executing my SQL statements. I have check communication between my server application and the client application without using oracle and its working fine, its only when I started executing SQL statements when I got this error.
    Can anybody help me with this problem or point me to the right direction on how to resolve this issue.
    thanks

    > I have tried what you suggested. I have created a
    seperate TOracleSession on each thread that I create
    on the OnConnect event however I am having Problems
    using the oraclesession created on the OnExecute
    event. Somehow it is still executing the SQL that I
    have created on the main form where I first opened an
    oraclesession component created on the main form.
    It sounds then like the TOracleSession object in the thread is a copy of the one in the main thread/form.
    > Do you think that It would work if I create an
    instance of the TOracleDatasets and TOracleQuery on
    the OnExecute event and also at the same time create
    my TOracleSession on this event and continue
    processing the data receive from the client server.
    I've never used the Indy components for threading. The default TThread class worked just fine for me.
    What I used to do is define the session and database objects as privates in my new thread class (let's call it TThreadSQL) - which was subclassed from TThread.
    The constructor of this new TThreadSQL class did the following (writing here purely from memory - have not done Delphi for some time now): constructor TThreadSQL.Create( TNSalias, username, password : string );
    // constructor is called with the Oracle session connection details
    begin
      inherited Create; // call the parent class constructor
      CreateOracleSession; // call own private method to create an Oracle connection
    end;
    The CreateOracleSession method would then:
    - create a BDE Session (TSession) object
    - create a BDE Database (TDatabase) object, using the BDE Oracle native driver and an Oracle TNS alias plus username and password for connection
    The destructor would close the connection. The Execute method which is used to fire up the thread, would use a TQuery object (or whatever) to execute a SQL using it owns connection.

  • Memory Leak with BC4J

    We seem to be having a memory leak problem with our first BC4J application. Using the memory profiler in JDev(9.0.2.1) I have noticed that every time I check out an application module using Configuration.createRootApplicationModule() an oracle.jbo.common.ampool.SessionCookieImpl object is created. Once the application module is checked back in using Configuration.releaseApplicationModule(am,false) the SessionCookieImpl object is still allocated. This happens on almost every page in my application, so the number of SessionCookieImpl object grows very quickly, and they never seem to get deallocated, even after several hours. Under heavy usage this is causing a huge problems.
    I am using the "Stateless" release mode in the configuration, and module pooling seems to be working flawlessly. It seems to me that there should be someway to deallocate these objects once a module is checked in.
    Am I doing something obviously wrong? Does anyone know how to fix this? Please help!
    Here are the config options I am using
    &lt;AppModuleConfig name="MasterModuleLocal"&gt;
    &lt;jbo.project&gt;WBS&lt;/jbo.project&gt;
    &lt;AppModuleJndiName&gt;###.###.wbs.bc.MasterModule&lt;/AppModuleJndiName&gt;
    &lt;DeployPlatform&gt;LOCAL&lt;/DeployPlatform&gt;
    &lt;JDBCName&gt;prod&lt;/JDBCName&gt;
    &lt;RELEASE_MODE&gt;Stateless&lt;/RELEASE_MODE&gt;
    &lt;jbo.ampool.dynamicjdbccredentials&gt;false&lt;/jbo.ampool.dynamicjdbccredentials&gt;
    &lt;ApplicationName&gt;###.###.wbs.bc.MasterModule&lt;/ApplicationName&gt;
    &lt;jbo.poolminavailablesize&gt;0&lt;/jbo.poolminavailablesize&gt;
    &lt;DBconnection&gt;jdbc:oracle:thin:@***.***.***.***:1521:prod&lt;/DBconnection&gt; &lt;jbo.doconnectionpooling&gt;true&lt;/jbo.doconnectionpooling&gt; &lt;jbo.ampool.minavailablesize&gt;0&lt;/jbo.ampool.minavailablesize&gt;
    &lt;/AppModuleConfig&gt;

    This made complete sense to me, so I rushed into work this morning. I haven't looked at that parameter since i first started doing some experiments with bc4j more than a year ago. At the time i assumed that using true would not put the module back into the pool, so I never tried using it.
    When I got to work this morning, i changed this param and unfortunately I could not see any difference at all in the behavior of the application.
    This is still a huge problem because we have several objects getting created every time a request for a module is made, and these are never deallocated. After just a few hours of normal use, these objects have consumed huge chunks of memory on the server.

  • Finding Process Memory Leak?

    I have been tracking down memory leaks in a Java server-based application. I recently ran the application for several hours, and monitored memory usage with both JConsole and the Unix �top� command. I encountered some behaviors that I don�t understand.
    With JConsole, I observed that the heap memory usage was fairly constant over time. The Code Cache space, however, gradually increased in size over the life of the test. I expected some increase as additional methods in the application were executed, but it seems that eventually the rate of increase would level out. It did not. Any ideas why that might happen?
    The resident memory (as reported by top) increased significantly over the life of the test. Using pmap and jmap, I was able to determine that the heap space was increasing (even though JConsole reported that the heap was constant.) So, it seems as though the heap usage of the application is constant, but the heap usage of the process is still growing? I am using Java HotSpot VM for Solaris (1.6.0-b105).
    Any suggestions or insight would be appreciated.

    I'm not sure exactly what you're saying, but it sounds like this:
    A tool that's monitoring the VM says the memory used by your objects is not increasing, but other tools say the memory the VM has taken from the OS is increasing.
    Is that the case? If not, nevermind--I've misunderstood.
    If that is the case, then it's totally expected. The VM doesn't usually give memory back to the OS. If it hasn't used up the amount specified by -Xmx (or the default if you didn't specify -Xmx), it's free to just keep grabbing memory from the OS, rather than running a full GC to reclaim memory that it has used for objects but that is no longer reachable.

  • How can I avoid memory leak problem ?

    I use Jdev 10.1.2 . I have a memory leak problem with ADF .
    My application is very large . We have at least 30 application module , each application module contain many view object
    and I have to support a lot of concurrent users .
    as I know ADF stored data of view object in http session .
    and http session live is quite long . when I use application for a while It raise Ouf of Memory error .
    I am new for ADF.
    I try to use clearCache() on view object when I don't use it any more .
    and call resetState() when I don't use Application Module any more
    I don't know much about behavior of clearCache() and resetState() .
    I am not sure that It can avoid memory leak or not .
    Do you have suggestion to avoid this problem ?

    ADF does not store data in the HTTP session.
    See Chapter 28 "Application Module State Management" in the ADF Developer's Guide for Forms/4GL Developers on the ADF Learning Center at http://download-uk.oracle.com/docs/html/B25947_01/toc.htm for more information.
    See Chapter 29 "Understanding Application Module Pooling" to learn how you can tune the pooling parameters to control how many modules are used and how many modules "hang around" for what periods of time.

  • KeyboardFocusManager reason for memory leak?

    Hi all,
    with a memory leak detector we found that our application has massive memory leaks after opening and closing a JDialog and the reason we found was the following:
    The KeyboardFocusManager has a private static HashMap in which the actual focus in each window is stored. This is done by storing key/value-pairs in the HashMap with window as a key and the Component having the focus on this window as the value. Now you can throw the reference to the component away by using e.g. theComponent.setEnabled(false) - the KeyboardFocusManager then stores the pair window/null in the HashMap - but we didn't find any callable method to remove a key/value-pair from the HashMap and so the reference to the JDialog (as the key!!) stays resident and we have the reason for the memory leak. Now I have a few questions to this problem:
    1. Is it right in your opinion, that there is no method to delete the entry from this Hashtable?
    2. If this is the case - we have the opinion that there must be a good time to delete this entry (e.g. when disposing the dialog). Do you see if there is an obvious reason that this opinion is false?
    3. If no do you think this problem can be accepted as a bug by sun
    Thanks in advance and greetings from
    Holger

    I have been seeing similar behavior; I too have not found all the
    leaks. I think I have slowed the allocation by replacing some of my
    'build array' functions with the combination of 'initialize array'
    followed by 'replace array subset'. The drawback to doing it this way
    is that you have a fixed maximum number of elements allocated just once
    rather than allowing an array to grow incrementally. Please let me know
    if you try removing build arrays and if that helps.
    By the way, there is a checkbox under the options menu to deallocate
    memory as soon as possible - if you don't mind that your program runs
    more slowly, this may help to avoid the problem, at least temporarily.
    -vinny
    ciossek wrote:
    > dear all,
    > my labview program needs an increasing amount of memo
    ry when running
    > (at the time about 12k/s) which leads to swapping memory on my hdd.
    > i have found out that calling cluster references like Controls[] or
    > decos[] leads to this kind of memory leak and made a work around for
    > that (simply calling it only once at runtime) but there are more
    > memory leak(s)which i cannot find. The bugs that i have found
    > searching the labview resources does not answer my problem.
    >
    > does anybody already found out more memory leak problems ?
    >
    > thanks

  • Memory leaks and multi threading issues in managed client.

    In our company we use a lot of Oracle, and after the release of the managed provider we migrated all applications to it. First the  things were very impressive : the new client was faster, but after some days applications that uses 100MB with old client goes to 1GB and up. The memory is not the only issue, we use a lot of multi threading, and we experience connection drops and not disposal, after 1 days working one of the application had over 100 sessions on the server. I think there is something wrong with connection pool and multi threading.
    Is someone experience same problems.
    Yesterday we went back with unmanaged provider. Now things are back to normal.

    connection drops: did you try to use "Validate Connection=true" parameter in your connection string?
    the new client was faster: are you sure with this statement? Even in 64bit environment? I got quite serious performance problems when running application under 64bit process: https://forums.oracle.com/thread/2595323

  • Memory leak with multi-threaded environment

    When starting an environment with the THREADED_MUTEXED
    or THREADED_UNMUTEXED mode parameter, the oracle OCCI API
    has a memory leak. This can be demonstrated by modifying
    the "occidml.cpp" demo program as follows:
    Replace line 26:
    env = Environment::createEnvironment (Environment::DEFAULT);
    with
    env = Environment::createEnvironment (Environment::THREADED_MUTEXED);
    And replace line 164:
    demo->displayAllRows();
    with
    for (int ii=0; ii<10000; ii++) demo->displayAllRows();
    Recompile and run the program, and use "top" to see the
    size of the process's used memory continually increase
    unbounded.
    I am using the Oracle 9.2.0.1.0 database on Linux,
    gcc version 2.96.
    Is anyone aware of a fix for this problem?

    Yeah, I did suffer from this.
    If possible , you can switch to using OCCI on Oracle 10G client , you will find no memory leak issue anymore.
    Another issue is that OCCI is using default connection-blocking implementation , if a DB connection is blocked by accident just like plugging out the network link, you can not get any timeout or connection closed indications. You must implement your own OCCI connection timeout strategy, and you must kill the thread/process you are using.

Maybe you are looking for

  • How do I get my Desktop to come up . . .

    ...using PSE 6?  I recently purchased Photoshop Elements 6, for my Macintosh OS X.  Though I've looked everywhere on the menu, I can't find a way to keep my desktop visible in the background and PSE 6 as a secondary window.  The only way I can get a

  • I can use boot camp for install OX

    I did recovery and I installed a special program, after it, I tried to install again office 2011 and I could not, using time machine thus, I think, that if I make a boot camp, I can install in other hard disk or boot camp using time machine, and run

  • How do i get message+  on my pc... my phone has crashed and i cant get my text messages from it.... please help

    how do i get message+  on my pc... my phone has crashed and i cant get my text messages from it.... please help

  • Product cost Collection - Revaluation

    I am trying to do the revaluation of product cost collectors at actual prices. My activity planning price entered manually (Rs.17500 - fixed) My activity actual price also entered manually (Rs.19500-fixed) Now I am doing the CON1/CON2 transactions. 

  • Unable to open  jar files in Fedora

    Unable to open jar files in Fedora core 5 and getting an error messege java -jar ezim.jar Exception in thread "main" java.lang.ClassFormatError: org.ezim.core.Ezim (unrecognized class file version) at java.lang.VMClassLoader.defineClass (libgcj.so.7)