Take the 2-minute tour ×

Ok so I have wrote a C# driver(Driver as in dummy program to call a stub not a device driver) program which invokes a C wrapper DLL and the C wrapper DLL invokes a java jar file through JNI which actually does most of the work. All 3 programs are 32 bit. This is done so as to integrate with another vendor which is supposed to do the C# as well as C program which calls our C DLL.

My sample test C# to C to Java program works fine but the problem is however, that when the vendor's actual C# program invokes our program, the Hotspot JVM either fails initialize outright or if it initializes properly, during the invocation of our function, it throws an OutOfMemory error. When I tried using JRockit JVM which does not need a contiguous heap space, the JVM causes the program to crash outright.

Development Platform is Windows 7 64 bit OS. Core i7, 8GB RAM Actual programs have to be 32 bit for backwards compatibility to older hardware/OS.

From my understanding, a 32 bit process normally has up to 2 GB of address space available to it. The peak total size taken from task manager that my driver program takes up is 256MB. The vendor's C# programs loads quite a number of other libraries but I highly doubt that they would occupy more than 700MB.

What could be the issue here? Is it that the address space is not contiguous? But if that is the case, why did JRockit crash outright since it can handle non-contiguous address spaces?

share|improve this question
This thing sounds like an insane design ;) It isn't a project for the military, is it ;)? –  paulsm4 Jun 28 '12 at 3:13
When using the Hotspot JVM - what is the initialisation error you get? –  Deco Jun 28 '12 at 3:16
256-700 MB RAM for a driver? WAT. Do you happen to work for Microsoft? –  Kevin Jun 28 '12 at 3:26
If they need a C# interface, I would write a C# library that you know works, and have them link against that. Make it a class library that creates a DLL, then they can have a reference to it. That way you are in full control of your insane process. ;) –  Charlie Kilian Jun 28 '12 at 3:33
" I have wrote a C# driver program which invokes a C wrapper DLL and the C wrapper DLL invokes a java jar file through JNI" - Oh my... –  Ed S. Jun 28 '12 at 3:36

1 Answer 1

There are far too many things that could be going wrong here to speculate which one it might be.

Some bits of advice:

  • It is a bad idea to try to debug a problem by developing a theory independently of the actual evidence. You have a theory that this is something to do with non-contiguous address spaces, (apparently) without any real evidence. Get some evidence first ...

  • Randomly changing variables (like trying a different JVM) is a bad approach, unless you've got some evidence that says that is the problem ... in your case.

  • If you are building stuff to run on a 32 bit platform and legacy operating systems, you need a 32 bit + legacy OS test environment for doing your routine development testing. (The wording of your question suggests that you don't have one.)

  • You need to reproduce the actual problem that the client is seeing. Get hold of their program and details of their hardware and OS and so forth, and try to set up a clone. If that's not possible, arrange a site visit where you can get direct access to their kit.

And finally. A system design that tries to cobble together C, C# and Java in the same process is technically risky to an insane degree. Whoever decided this was a good idea needs to be re-educated.

share|improve this answer
This software has to run on both the latest OSes as well as be backwards compatible for older OSes hence the delveopment testing –  shawn Jun 28 '12 at 9:26
If I get either an OutOfMemory or heap size error, what would be your theory on the cause of it? –  shawn Jun 28 '12 at 9:50
@shawn - 1) I didn't say you should stop testing on the latest platform as well. 2) I'm not going to guess. You should reproduce the problem ... –  Stephen C Jun 28 '12 at 10:36

Your Answer


