JNI - Garbage collector freeze ?

J

julien

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
 
J

jlp

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

Hendrik Maryns

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

julien

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 ;)
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,
 
H

Hendrik Maryns

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

julien

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

Tom Anderson

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top