开发者

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 i开发者_C百科s 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜