'How expensive is Runtime.getRuntime() in combination with getting the memory metrics

How performance intense is Runtime.getRuntime() in combination with getting the memory metrics (free memory, used memory, etc.). I am considering using it to monitor memory consumption in the application to troubleshoot a memory problem on production code, but I'm wondering if it will be an expensive process that slows down the response of the web application. Let's say for example if you are using in a polling fashion. If you poll let's say every 5 seconds for example or every minute. Will this have a significant impact on the application?



Solution 1:[1]

The performance is essentially the same, because the essentially the same thing is happening in both cases.

One drawback - If the child gets stuck in a loop or is generally sloppy with resource management, the parent suffers too.

Performance will be the same.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Innomight