Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ways to measure memory consumption while running JUnit tests

Tags:

I need to measure how much of memory do my JUnit tests consume.

  1. So the most obvious (but not convinient) way is to run JVM with arguments like "-Xms128m -Xmx512m" and track when I'll get the OutOfMemory error.

  2. The second way is to request a heapdump after running all my tests and then use Memory Analyzer Tool. But it isn't useful to do this every time I'm running tests.

The desired way is, let's say, to log memory consumption into a file with such values as maximum memory consumption, average consumption, GC calls count etc. Or even draw a diagram which will show how memory was used.

And the question is, are there any tools, or methods, or instruments to do this? Or, maybe, my wishes are unreal and naive and there is no way to gather such data?

Tests are running under IntelliJ Idea with JUnit4. I'm free to use any other environment. Thanks in advance for any advice!