LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Allocation problem when using JNI

Solved!
Go to solution

For a Project we need to interface Labwindows-CVI/ Teststand with an application written in Java. we are using JNI. The code uses JNI_CreateJavaVM to start a JVM to run the Java interface code. The code did run for some time , but now ( without any obvious change nor on the CVI side neither on the Java side) JNI_CreateJavaVM fails with -4 error code, that means that the start of the JVM failed due to memory allocation failure. First investigation showed, that even if Windows Task Manager shows about 600M free physical memory, you can allocate in CVI only about 250M as a single block at the time we are calling  JNI_CreateJavaVM. That might be a little bit to less as we need to pass -Xmx192m to the JVM to run our code. Unfortunately just increasing the physical memory of that machine from 1.5G to 2G doesn't change anything. The free memory showed by Task Manager increases, but the allocatable memory block size does not. Are the any trick to optimize CVI/Teststand for that use case ?  Or maybe known problems with JNI ?

0 Kudos
Message 1 of 3
(5,566 Views)

hi,

 

have you tried other functions to allocate memory?

the -Xmx command only sets the maximum heap size. You can try to use -Xms. This command sets the initial Java heap size. 

 

0 Kudos
Message 2 of 3
(5,539 Views)
Solution
Accepted by topic author mkossmann

Finally it was a memory fragmentation issue caused by TestStand. Details/workaround see here

0 Kudos
Message 3 of 3
(5,522 Views)