Possible causes for memory leak in Java and Tomcat

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

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

Similar Messages

  • About Memory Leak in JAVA Any body pls help me

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

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

  • Memory Leaks in Java

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

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

  • How to configure license file for Memory Leak tool and WL Server 9.2?

    (I posted to general JRockit forum before realizing existence of this forum which is probably more applicable.)
    Here's our problem:
    Running latest version of WL 9.2 MP3 and JRockit Mission Control 3.0.1
    Able to run Mission Control, and connect to the WL Server and to run View Console with no problems.
    I can't get Memory Leak tool to run because it complains about needing a license file.
    First I tried with off the shelf WL 9.2 MP3.
    Get error:
    A license for Memory Leak Detector could not be found on the JRockit at (1.5) weblogic.Server (192).
    Error: Can not find component Memory Leak Detector for JRockit * in the license file. Please check http://www.jrockit.com/license for license updates.
    So I downloaded license file from JRockit download site - wls92.zip. It contains several files, but no clear instructions on what to do with these files. I copied one of these files "LIC-WLSP92.txt" to my JRockit home as C:\bea\JROCKI~1\jre\license.bea
    Tried again. Restarted WL server. Restarted JRockit Mission Control.
    Get error: A license for Memory Leak Detector could not be found on the JRockit at (1.5) weblogic.Server (3052).
    The license file does not exist at: C:\bea\JROCKI~1\jre\license.bea
    Any advise on how to install license or who to contact for help?

    Installed Mission Control 3.0.3.
    Got following message when I attempted to run Memory Leak:
    A license for Memory Leak Detector could not be found on the JRockit at (1.5) weblogic.Server (192).
    Error: Can not find component Memory Leak Detector for JRockit * in the license file.
    Please check http://www.jrockit.com/license for license updates.
    I believe that we're using the latest downloads of WebLogic 9.2.x and JRockit.
    WebLogic is running using 9.2.3 and JRockit build R27.4.0-90_CR358515-94243-1.5.0_12-20080118-1154-windows-ia2
    Contents of C:\bea\jrockit_150_12\jre\license.bea:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <bea-licenses>
    <license-group format="1.0" product="JRockit" release="*">
    </license-group>
    </bea-licenses>
    Could WebLogic be misconfigured?
    Any diagnostics to help figure out the licensing?
    Any other ideas?

  • 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

  • Whether our application caused the memory leak

    whether have the command to find out whether our application caused the memory leak !
    We are using Jdev10g + JHeadstart(Release 9.0.5.1, BC4J + Struts + JSP) to build our enterprise application,
    but when the application running some days in our Application Server(RedHat AMD64, with 8GB RAM), the memory consumed was growth seriously in production environment (one OC4J instance will caused almost 2G memory ulilization after running 2 days) that is caused us to restart the instance each day ! we doubt and worry
    about maybe our application suffer the memory leak problem, so we want to know have the command to find out whether our application caused the memory leak
    issue and which program is the major murderer for memory.

    Ting,
    Unfortunately there is no 'command' that will show you the location of a memory leak. First I would scrutinizing your code for any obvious 'leaks'. Then, you should obtain some statistics about the usage of your system. One important aspect is how long a HttpSession usually lives. If you have thousands of users that stay online the entire day and never 'time out', and if you have users on the system 24 hours a day, then the sheer number of HttpSessions might be a problem.
    JHeadstart 9.0.x tends to have rather 'heavy' session objects. This can easily be solved by adding some actions to clear up DataObjects and DataObjectSets of previous 'Groups' when entering a new Group. A good place would be between the 'DynamicActionRouter' and the 'ActionRouters'. Just before entering the 'EmployeeActionRouter', you could remove all DataObjects and DataObjectSets that might be left on the Session by actions of the other ActionRouters.
    Also it would be interesting to see if the garbage collector can do its thing when the system is less busy. For instance, if your application has a smaller load during the weekend, what is the memory usage on Sunday at midnight compared to, say, Friday at noon. Has the memory load dropped consistently with the decreased number of online users, or does too much memory stay allocated? If so, then there's more going on than just HttpSession objects.
    If all this does not lead to a solution, I suggest using a profiling tool such as OptimizeIt to investigate the memory usage of the application in detail.
    Kind regards,
    Peter Ebell
    JHeadstart Team

  • Find out whether our application caused the memory leak

    whether have the command to find out whether our application caused the memory leak !
    We are using Jdev10g + BC4J + Struts + JSP to build our enterprise application,
    but when the application running some days in our Application Server(RedHat AS3-86, with 4GB RAM), the memory consumed is serious ! we doubt and worry
    about maybe our application suffer the memory leak problem, so we want to know have the command to find out whether our application caused the memory leak
    issue and which program is the major murderer for memory.

    The second scenario is, as we perform some deployment activity on 10g, the memory usage chart shows a sharp consumption of memory about 1.5GB .the loss memory almost be display in "other" legend chart !
    Please give us some advice , thanks in advance

  • 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

  • Finding memory leaks in java

    Hello,
    I have a memory leak in my application. I have found other memory leaks in the software using JProfiler, but I have a problem with JProfiler finding this one. My biggest problem is the JProfiler itself. If I use short runs, the JProfiler works fine. If I run my application for more than half a day, the JProfiler eats up memory and after a while it stops responding.
    I tried JProbe, but after profiling my application for 18 hours straight, it got buggy and wouldn't work correctly. It also ate up alot of memory, and couldn't process my snapshot after 18 hours of run. I saved all snapshots, and restarted JProbe. The initial snapshot was read correctly, but the final snapshot threw an NegativeArraySizeException.
    So, now I am looking for other tools which are able to find memory leaks without hanging or crashing after running 24 hours. Any recommendations?

    I dont know any other profiler you can use, but how about using the divide and conquer approach?
    Disable a significant section of your application and let it run for a day. If the leak occurs, its in the non disabled part.
    If it doesn't, its in the disabled part. Next, enable all the code. Then disable about half of the half that failed and try that. Continue doing so until
    you isolate the code enough that you can look at it and hopefully find the problem. Note you will need to keep track of what you previously enabled and disabled as a test (I put comments in the code).
    Alternately, you can look at functions that perform complex functionality that you suspect might be the problem and have the function return
    dummy data rather than perform the functionality. If the leak goes away, its that function(s).
    Example:
    public String getComplexData(String arg1, String arg2){
    //this section bypasses the complex code and returns dummy data
    boolean x1= true;
    if(x1==true)
    return new String("some dummy data");
    //complex functionality goes here.
    Also of help would be to list everything that can cause a memory leak (I assume its a memory leak and not a resource leak such as not closing connections).
    Here are some ideas:
    1) persistant class variables that are a collection that have objects added to them but never deleted and allowed to be garbage collected
    such as static class variables, session scope variables, or application scope variables.
    2) An object tree where one of its nodes is never set to null to be garbage collected (such as a static class variable).
    If you are running a web application in a clustered enviornment, try running it on only one server.

  • By any chance long living filestream object cause unmanaged memory leak?

    Hi,
    I am running my application where in I have one file stream object which live for long duration, say its life time is equivalent to life time of application. So by any chance this kind of object causes unmanaged memory leak in the application. Because when
    I see private bytes for my application, it is higher than the all bytes in heap counter. That mean there is a unmanaged memory leak. So does such filestream object cause such behaviour?
    Thanks and Regards,
    Lucas

    What makes you think it's the file stream that leaks unmanaged memory? There could be other parts of your applications that do that.
    FileStream doesn't usually allocate unmanaged memory. Its internal buffer is a GC heap allocated byte[] array. The only unmanaged memory allocation that I know of in FileStream is a OVERLAPPED structure used for async I/O. If you use BeginRead/Write make
    sure you call EndRead/Write correctly, otherwise that structure may be leaked.
    @Joel Engineer: "When a stream uses ASCII encoding under certain cases nulls are added to the data for block alignment."
    FileStream doesn't have anything to do with text encoding and I've told you that before. Next time when I run into a post that makes such a claim I'll simply delete it. This display of ignorance has lasted more than enough.

  • Memory Leak in  Java

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

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

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

  • Mac book pro hanging very often what will be the possible cause for it?

    hi my mac book pro is 3months old and nowadays its hanging very often like when iam surfing, and some times when i dont use it for 10 to 15min.
    can anybody suggest me what will be the possible cause for it.
    Thanks

    Start with this comprehensive troubleshooting article:
    https://discussions.apple.com/docs/DOC-3521
    Look at this one for possible solutions:
    https://discussions.apple.com/docs/DOC-3353
    Ciao.

  • What are possible causes for frequent loss of wireless mouse connectivity other than the batteries ?

    What are possible causes for frequent loss of wireless mouse connectivity other than the batteries ?

    Wi-Fi or another interference source. Try turning off the Wi-Fi and see if the problems continue. If that solves the problem, see if you can set your Wi-Fi to run in the 5 GHz range.
    Keyboard/Mouse – Troubleshooting Wireless
    WIFI AND BLUETOOTH FINALLY SOLVED, NO REALLY - YOSEMITE 10.10
    Bluetooth Wireless Problems
    Bluetooth devices become unresponsive

  • How to install Java and Tomcat on my VPS

    Hello,
    I am new in Java.
    I would like to install Java and Tomcat on my VPS server.
    Do you know which doc or info i should read?
    Thanks a lot.
    Gil

    The free Perian will do it for you automatically.
    Additional free new machine setup stuff:
    Install and update your Flash here
    http://get.adobe.com/flashplayer/
    Install Perian (addiitonal Quicktime codecs)
    http://perian.org/
    Install the Unarchiver (uncompress software)
    http://wakaba.c3.cx/s/apps/unarchiver.html
    Flip for Mac (for Windows media in Quicktime)
    http://www.telestream.net/flip4mac-wmv/overview.htm
    VLC (plays anything just about)
    http://www.videolan.org/
    Easy Find (finds everything on a Mac)
    http://www.devon-technologies.com/download/index.html
    OnyX (maintenance, cleanup, repair utility)
    http://www.titanium.free.fr/

Maybe you are looking for