views:

76

answers:

2
+2  Q: 

java blocks memory

I have a java program that uses a weak hashmap for caching some things, if java needs more memory the weak hashmap is cleared. This works fine for me. Now I also have a c# program on the same computer running and recognized the following.

When the java program is running my c# program is not running correctly at times when the computer is highly stressed. On the other hand my c# program also runs fine at these times when the java program is not running.

Could it be that my java program blocks memory that my c# program could use? How can I find this out?

+2  A: 

Your Java program will expand it's heap to a given size. Garbage collection will free objects returning them to the heap's free space, but will not reduce the overall memeory used by the Java program.

Use your OS capabailities to investigate the memory consumed by the C++ and Java apps.

You can use command line options on your JVM to control the maximum heap size for Java, and hence limit how hungry it will be. Of course if you need a huge heap then it's possible that everything won't fit on the one machine.

djna
These parameters are turned on, is there a possibility to use such parameters in .net/c#-environments as well?
Xelluloid
It's not just turned on, but what they are set to that matters - do the maths, measure what the c# needs, add on your max for Java - does it fit? Do you see memory running out when your c# has problems? I'm a Java chap, afraid I don't know about controlling c#.
djna
read this link http://www.caucho.com/resin-3.0/performance/jvm-tuning.xtp and this linkhttp://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac55070_.htm
Reddy
+2  A: 

You can't set a maximum bound for your .net CLR's heap in the same way that you have for your JVM's heap. See this question for some more info. The CLR will simply attempt to expand its heap until it hits your OS-imposed process memory limit, or your machine's free memory is used up.

So yes, when you increase your JVM heap size you could reserve memory that your CLR would otherwise use. The JVM will start at the lower bound and expand to the upper bound if needed. As mentioned above, that memory is not freed up outside the JVM - it is not made available to the .net CLR.

You'll need to do some more monitoring to see if memory really is the cause of the problem though.

serg10