I'm in process of aligning my Java agent which mainly does two tasks, One to create Oracle table based on Oracle table configuration domino form and second to push Lotus Notes documents to Oracle.

Unfortunately I haven't used recycle () correctly which leads memory leak and then overflow error. Once I get "Overflow" error, I can't run my Java agent. Every time I try it says same error doesn't matter if I try only with ,

System.out.println("hello world");

I thought if I restart my domino server it will kill hanged threads but I get same error even if I restart my domino server. However, when I restart my client it fixed the problem. So my question are,

* How does Java threads are connected to Notes client?

* How to kill Java threads without restarting Domino server?

16 Responses to "Overflow-Memory leak : What am I suppose to do ?"

  1. gravatar NotesSensei Says:

    Recycle, Recyle, Recycle.
    Nothing else will fix it.
    There is no workaround to broken code.

  2. gravatar Narasimha Reddy, Lomadi Says:

    http://www-10.lotus.com/ldd/nd85forum.nsf/ShowMyTopicsAllFlatweb/31b6914fa765d00a8525767e00302728?OpenDocument


    NarasimhaReddy, Lomadi.

  3. gravatar Narasimha Reddy, Lomadi Says:

    http://www-10.lotus.com/ldd/nd85forum.nsf/ShowMyTopicsAllFlatweb/31b6914fa765d00a8525767e00302728?OpenDocument


    Narasimha Reddy, Lomadi

  4. gravatar Henning Says:

    If Java veterans (No, not me but people that really know how to develop software in Java) crash your Domino server because they have missed some proper recycling then things are at least improvable. I know of a company that has disallowed the usage of Java in a Domino context because of this behavior.

  5. gravatar Anonymous Says:

    In an agent you do not recycle the session object. The agent will do that.

    You need only recycle other objects to clean up memory if you are using a lot (eg, cleaning up documents as you go in a loop).

    In Java applications it is a different story. You must recycle everything when finished.

    Depending on the Java agent/application executes depends on where you need to restart if something goes wrong. If the code executes on the client, then the client memory will be locked. If you are using NCSO.jar or Notes.jar on the server then the server memory will be locked.

    Looking at your earlier blog posting, are you using jars as a shared resource? or putting them into your ext/lib folder?

  6. gravatar Rishi Says:

    @Simon,

    Yeah, I'm using external jar ( odbc ) which resides in ext/lib folder of the agent.

  7. gravatar Rishi Says:

    @Narasimha,

    So do you suggest everything should be wrap up inside jar file ?

  8. gravatar Rishi Says:

    @Henning,

    So, Domino is not good for building Java apps ?

  9. gravatar Henning Says:

    Oh no that was not my intention. Java is the way to go for Domino (everything else is put on hold anyway). The Java garbage collector normally is quite good so you normally don't have to care much about recycling in Java. At least if you use an application server that is written in Java. Most parts of the Domino server seem to be written in C(++) so you just have to care about some things yourself.
    I know IBM will probably not agree but you can really do nasty things in Lotusscript and it will NOT kill your server while forgetting to recycle can bring a Domino server down quite easily. It should not be like this.
    But again Java is the way to go for every Domino developer. Once you know how to handle it things will run smoothly.
    And it is great that what you learn now is available to others that want to do stuff in Java on a Domino server. Thank you for this.

  10. gravatar Rishi Says:

    @Henning,

    Agree..Domino Java is still not reliable and easy compare to Lotus Script.Designer help says Recycling a parent recycles all the children. So, if I recycle "Session" all related children like Database,View, doc everything should be recycled.But, Some blogs are contradicting this.Still couple of things I'm not very sure in Domino Java agents. For example, my main class calling three different classes and all these classes require session object. Should I pass "session" object as a argument to all these classes from main class or should I create session object in each class ?

    E.g;
    ------

    notesmain() {
    Session s=getSession();
    Animals cat= new Animals();
    cat.getName(session);
    }

    or

    notesmain() {
    Session s=getSession();
    Animals cat= new Animals();
    cat.getName();
    }

    public class Animals() {
    public cat () throws Exception {
    Session s=getSession();
    }

    }

    Thanks for you insights.

  11. gravatar Lemmy Caution Says:

    One basic point:
    If u get OutOfMemoryException when u r running the agent, its probably due to not recycle enough INSIDE LOOPS (the Document oldDoc = doc; oldDoc.recycle()-thing u posted elsewhere.

    If u get an OutOfMemoryException any 5 or 6 days (or any 2 or 3 weeks, etc.) u have a real memory leak problem, which is more difficult to find.

    Good news is, that this second case isn't very probable, if you program java with some respect for design principles and not like angry (or evil) hacker.
    The recycle()-problems that are due to the first case are quite easy to spot. Just look at your loops and recycle stuff there!

    Trust me...

  12. gravatar Bjørn Cintra Says:

    First of all, this is a very good resource on domino and java: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Java_memory_management_in_NotesDomino

    Read it! :)

    Second: Domino and java works fine, but you need to take care to clean your stuff (aka recycle), especially Documents and ViewEntries in a loop. It can be a good idea to clean items and other things you use inside of loops as well, just to make sure. Better safe than sorry is my motto.

    Personally, I would have passed the session around, but it is possible to store it in a thread context, or something like that, if you don't like passing it around. I mostly work in web, so the session is usually generated for me, so it has to be passed around.

  13. gravatar Rishi Says:

    @ Bjorn:

    Thanks,Great article.I'm looking into it. Even I'm passing session around the the classes but memory leaks really giving me second thought on everything I wrote.

  14. gravatar Rishi Says:

    @AxelJanssen:

    Thanks for your insights.Do we have any article or tech note which explains Domino Java program design principles ?

  15. gravatar Anonymous Says:

    Once you know how the recycle() works then coding Java apps for Domino is easy and you should not experience memory issues.

    I would recommend reading Bobs blog. It is a 3-4 parter. Starts here.
    http://www.bobzblog.com/tuxedoguy.nsf/dx/geek-o-terica-5-taking-out-the-garbage-java

  16. gravatar suresh m Says:

    Hi Rishi, i have sent one mail regarding the Lotus Notes issue. Can you please reply to that mail.

Leave a Reply

preload preload preload