I need to measure how much of memory do my JUnit tests consume.
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.
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!
Answer
You can use JConsole,
http://docs.oracle.com/javase/6/docs/technotes/guides/management/jconsole.html
It comes with your JDK
No comments:
Post a Comment