Results 1 to 4 of 4
Thread: JNI Memory Allocation
- 09-16-2010, 02:23 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 6
- Rep Power
- 0
JNI Memory Allocation
Hi,
I have a problem with a self written c++ dll.
The dll needs a bit of memory, about 500MB to 1GB but crashes during dynamic allocation.
The memory allocation is not influenced by any parameter passed from the original java program via the JNI. If it is solely executed as a simple cpp.exe it works absolutely fine, it only crashes as a by JAVA called dll.
Due to plenty of couts I am definitely sure that it crashes executing the following line of code:
data = new float[TABLE_SIZE];
whereas data is a float pointer and TABLESIZE is about 37 million entries. Hence it needs 150 MB space.
But instead of allocating, it crashes with the error message:
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!
Program: C:\Program Files (x86)\Java\jre6\bin\javaw.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
---------------------------
OK
---------------------------
This happen although I still have 1.8 GB free RAM.
Does anybody know how JAVA can provide more memory to the dll?
Thanks a lot!
- 09-16-2010, 03:24 PM #2
Try using a -Xxxx option (get the value of xxx from the javac doc) on the java command to give the JVM more memory.
Here's an example: -Xmx512M
- 09-16-2010, 03:48 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,414
- Blog Entries
- 7
- Rep Power
- 17
That doesn't work; the Java heap and the C or C++ heap are two different things (running in the same process space). If you increase Java's heap the less memory is available to your C or C++ JNI code. Here's a nice link that explains memory management for the both.
kind regards,
Jos
- 09-16-2010, 05:00 PM #4
Member
- Join Date
- Sep 2010
- Posts
- 6
- Rep Power
- 0
Thanks, but I cannot find where I can actually influence how Java determines the C++ Heap Space. I do not need to reference JNI objects, the memory allocation is simply made by method deep down in the cpp code that does not have to do anything with arguments passed from Java to the dll.
Similar Threads
-
Memory Allocation
By zzpprk in forum Advanced JavaReplies: 2Last Post: 03-16-2010, 01:14 AM -
Array memory allocation
By number5isalive in forum Advanced JavaReplies: 8Last Post: 10-14-2009, 08:04 AM -
Memory Allocation
By kishan in forum New To JavaReplies: 3Last Post: 09-19-2009, 05:47 PM -
Resource management allocation
By jyothi.priyanka in forum New To JavaReplies: 0Last Post: 04-04-2009, 01:25 PM -
how do I increase memory allocated to code cache (Non Heap Memory)
By manibhat in forum Advanced JavaReplies: 2Last Post: 08-21-2008, 07:33 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks