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?
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.