JNI - Garbage collector freeze ?

Discussion in 'Java' started by julien, Jul 25, 2008.

  1. julien

    julien Guest

    Hi,

    There is my problem.

    First part : I have a java programme that makes some operation, create
    a list, ..;
    Second part : I have unrealIRC
    I need to make a unrealIRCD module that talk to the java program. This
    is the plan.

    So to do this, i have make a plugin, that instanciate JVM via JNI and
    create an instance of my java class and call a method < String
    makeOperation(String param) >

    Problem is : in java code i have a System.gc() call. When this code is
    execute, unrealIRCD freeze. I have no stack trace, no GC log, nothing,
    just freeze. Garbage collector seems to wait something ? After that i
    have test to call System.gc() in the class constructor and it works..

    If i comment the line in my makeOperation function, its works for few
    operations and freeze, i think, when the garbage collector is launched
    by the JVM.

    I have not a good knowledge about garbage collector. If someone have
    an idea about this freeze, please help me ;)
    Thanks
    julien, Jul 25, 2008
    #1
    1. Advertising

  2. julien

    jlp Guest

    julien a écrit :
    > Hi,
    >
    > There is my problem.
    >
    > First part : I have a java programme that makes some operation, create
    > a list, ..;
    > Second part : I have unrealIRC
    > I need to make a unrealIRCD module that talk to the java program. This
    > is the plan.
    >
    > So to do this, i have make a plugin, that instanciate JVM via JNI and
    > create an instance of my java class and call a method < String
    > makeOperation(String param) >
    >
    > Problem is : in java code i have a System.gc() call. When this code is
    > execute, unrealIRCD freeze. I have no stack trace, no GC log, nothing,
    > just freeze. Garbage collector seems to wait something ? After that i
    > have test to call System.gc() in the class constructor and it works..
    >
    > If i comment the line in my makeOperation function, its works for few
    > operations and freeze, i think, when the garbage collector is launched
    > by the JVM.
    >
    > I have not a good knowledge about garbage collector. If someone have
    > an idea about this freeze, please help me ;)
    > Thanks

    I don't know what is your problem, but it is a bad idea to use
    system.gc() in your code. Let the GC do that...
    jlp, Jul 25, 2008
    #2
    1. Advertising

  3. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    julien schreef:
    | Hi,
    |
    | There is my problem.
    |
    | First part : I have a java programme that makes some operation, create
    | a list, ..;
    | Second part : I have unrealIRC
    | I need to make a unrealIRCD module that talk to the java program. This
    | is the plan.
    |
    | So to do this, i have make a plugin, that instanciate JVM via JNI and
    | create an instance of my java class and call a method < String
    | makeOperation(String param) >
    |
    | Problem is : in java code i have a System.gc() call. When this code is
    | execute, unrealIRCD freeze. I have no stack trace, no GC log, nothing,
    | just freeze. Garbage collector seems to wait something ? After that i
    | have test to call System.gc() in the class constructor and it works..
    |
    | If i comment the line in my makeOperation function, its works for few
    | operations and freeze, i think, when the garbage collector is launched
    | by the JVM.
    |
    | I have not a good knowledge about garbage collector. If someone have
    | an idea about this freeze, please help me ;)

    Seems like the gc wants to clear some objects which are still needed on
    the C side. Carefully check.

    H.
    - --
    Hendrik Maryns
    http://tcl.sfs.uni-tuebingen.de/~hendrik/
    ==================
    http://aouw.org
    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.9 (GNU/Linux)
    Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

    iEYEARECAAYFAkiJs+wACgkQBGFP0CTku6PGUwCgkBtjCfEiVplLrkeraNUlBITX
    CbMAnju1p3VIqGTMIbh86+/yHin9o60T
    =d96G
    -----END PGP SIGNATURE-----
    Hendrik Maryns, Jul 25, 2008
    #3
  4. julien

    julien Guest

    > jlp
    Thanks for the comment. I know that used System.gc() is currently a
    bad idea. I have just used that to improve that was the GC the source
    of my problem. In fact the GC is not the problem, its me ;)

    > Hendrik

    Thanks too. I will try to check and recheck my C jni object and add
    NewLocalRef, newGlobalRef etc. There is a way to know that var the GC
    wait for cleaning ?

    Regards,
    julien, Jul 25, 2008
    #4
  5. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    julien schreef:
    |> jlp
    | Thanks for the comment. I know that used System.gc() is currently a
    | bad idea. I have just used that to improve that was the GC the source
    | of my problem. In fact the GC is not the problem, its me ;)
    |
    |> Hendrik
    | Thanks too. I will try to check and recheck my C jni object and add
    | NewLocalRef, newGlobalRef etc. There is a way to know that var the GC
    | wait for cleaning ?

    I’m sorry, I don’t understand you. Ask someone to review your English.
    ~ Or try in French, and I’ll translate.

    H.
    - --
    Hendrik Maryns
    http://tcl.sfs.uni-tuebingen.de/~hendrik/
    ==================
    http://aouw.org
    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.9 (GNU/Linux)
    Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

    iEYEARECAAYFAkiJvjQACgkQBGFP0CTku6MD+ACcCZV64+QjkPyFYwhrvwtaotzk
    hEoAn0o+JZuqQe/w3xx7tPQB0BPJzFhg
    =/cCu
    -----END PGP SIGNATURE-----
    Hendrik Maryns, Jul 25, 2008
    #5
  6. julien

    julien Guest

    sorry....

    Just want to know if a method exists to find what object in my C code
    the GC wants to clear without success.

    ---

    Désolé,
    Je voulais juste savoir si une méthode existe afin de savoir quel(s)
    objet(s) le garbage collector essaye de supprimer sans y arriver.

    Thanks.
    julien, Jul 25, 2008
    #6
  7. julien

    Tom Anderson Guest

    On Fri, 25 Jul 2008, julien wrote:

    > sorry....
    >
    > Just want to know if a method exists to find what object in my C code
    > the GC wants to clear without success.


    I kind of doubt that's what the problem is. The GC will never try to
    delete objects on the C side, only the java side.

    What might be happening is that the C side is starting a critical section,
    during which GC cannot run, and the java side is out of memory, so it's
    waiting for the C side to end the critical section. I think the OP should
    modify his JVM startup code to add -Xcheck:jni to the JVM parameters, and
    see if that catches any JNI mistakes,

    If that doesn't work, he should add a bunch of GC logging flags, and see
    if he can make sense of the output.

    tom

    --
    No noon today. Noon tomorrow. There's always a noon tomorrow.
    Tom Anderson, Jul 25, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Tillie

    Garbage Collector Debugging

    Rob Tillie, Aug 15, 2003, in forum: ASP .Net
    Replies:
    11
    Views:
    1,743
    JerryK
    Aug 18, 2003
  2. Pyramis
    Replies:
    0
    Views:
    388
    Pyramis
    Jan 25, 2004
  3. Colt

    Garbage collector problem

    Colt, Nov 15, 2003, in forum: Java
    Replies:
    9
    Views:
    672
    Tim Ward
    Nov 18, 2003
  4. bart59
    Replies:
    0
    Views:
    491
    bart59
    Jun 17, 2004
  5. Replies:
    5
    Views:
    233
    Olivier Renaud
    Mar 15, 2007
Loading...

Share This Page