JNI Stack Problem

D

DAnny K

Hi, I have a problem with the JNI in that I am trying to run some C
code using a Java GUI. The problem is is that I create some v large
arrays in my c code that the JVM apparenty cant deal with. - arrays of
say 50,000 elements. I have tried to increase the stack size using the
-Xss argument, but it still gives me this error

An unrecoverable stack overflow has occurred.
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_STACK_OVERFLOW (0xc00000fd) at pc=0x00971ee7, pid=3784,
tid=2740
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_02-b09 mixed mode)
# Problematic frame:
# C [freqLib.dll+0x1ee7]
#
# An error report file with more information is saved as
hs_err_pid3784.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#

Ta for any help in advance
 
G

Gordon Beaton

Hi, I have a problem with the JNI in that I am trying to run some C
code using a Java GUI. The problem is is that I create some v large
arrays in my c code that the JVM apparenty cant deal with. - arrays
of say 50,000 elements. I have tried to increase the stack size
using the -Xss argument, but it still gives me this error

An unrecoverable stack overflow has occurred.

The solution is simple: don't create objects of that size on the
stack. Instead, use malloc() or one of its friends to dynamically
allocate the array. Don't forget to free() it afterwards.

/gordon
 
V

Vitaly

The best solution is not using of Stack and Local Heap memory in jni. As
these are used by JVM. In MS Windows (if it possible) I use Global Heap or
Virtual Memory in my JNI code.
 

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,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top