JNI question

O

osamah_abuoun

Hi all :

when i am using JNI to excute a program in C , the java raised
EXCEPTION_STACK_OVERFLOW , the c program a very huge data , i tried
to increase the stack size for JVM via the option -Xss and put it to
64MB , but it isn't work also , so my question , is there any option
for JNI especially for this case , i mean can i increase the stack
offered for JNI to complete its work .
Note : the executable file for the C program works properly,
and i'm using winXP and win2k .

Thankx
 
J

Joseph Millar

-Xss only works for stack sizes for new Java threads you create. it won't
change the stack size for the JVM itself.

No, it works on all threads in the JVM as well, except for the
main thread, which exists prior to the option being processed.
There are OS dependent methods of growing the stack for a thread
but I do not know if the HotSpot JVM does this, I would have to
do some investigation.

In any event, you can use OS specific tools to expand the stack
size used by an executable which is usually stored as part of
the executable itself. The rules for stack size on the main
thread of a process are going to be very OS specific.
Try using JDK 1.3, I think it has a larger stack. Maybe it will
be enough for the C code.

Do you know by how much? And where did you find this information?
I'm curious.

--Joe
 
S

soft-eng

Joseph Millar said:
No, it works on all threads in the JVM as well, except for the
main thread, which exists prior to the option being processed.

I am not sure that the JNI calls use the Java thread's stack space,
or whether their stack comes out of the program stack. I would think they
don't use the Java thread stack, because you can attach
a C thread to a Java thread.
Do you know by how much? And where did you find this information?
I'm curious.

I haven't researched this much lately -- there was a JNI program
that required a big C++ stack (large on-the-stack array
variable declaration), that worked in 1.3 but ran
out of stack in 1.4.1. I checked the size of the "java.exe"
stack for both versions, and it seemed it had been
reduced by quite a bit.
 
S

soft-eng

Joseph Millar said:
Hmmmm...just for fun, I checked the stack sizes stored in
both the 1.3.1 and 1.4.2 java.exe program. Both are identical
at 256k reserved, 4k committed. So unless the JVM is playing
games with the stack size after the process starts (always
possible), the default appears to be unchanged, on Win32 anyway.

You are right, I mis-spoke -- the difference I saw was between
1.2 and onwards (not 1.3 and 1.4.) It was for 1.2.2 that
I saw the stack reserved size as 1024K (100000 hex), and for
later versions it had been cut down to 256K.
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top