Measure transient memory and performance programmatically
We have an application where we have a use case to have tests around the application performance. We run the candidate build against the build currently being used and compare stats like time taken for different operations, memory consumption of the operations and various 开发者_高级运维other general metrics like the total heap size etc...
My problem here is the measurement of transient memory during an operation. We have observed that to be fluctuating(too much to be reliable). I am using JMX and polling the JMX bean at an interval of 1 second...
One silution we tried(still testing) is to reduce the polling time to 10 ms. Not sure if that will help...
anybody has any other better ideas or have encountered same problems ?
Thanks, Kichu
Another tool which might be useful is jstat. This records periodically how much memory is consumed in each generational space and a cause for a GC being performed.
However, it sounds like you are creating so much garbage that the tools are giving you noisy information. The best tool sounds like using a memory profiler, which will give you much more detail about object allocation and where memory is being consumed. I suggest you try YourKit on eval and look at object allocation hot spots and try to reduce the amount of objects you create.
Try logging garbage collection. This will print out a message whenever gc happens, and you can use that message to see how much memory your program is using.
This is an example of the output,
[GC 19062K->7172K(60800K), 0.0087190 secs]
[GC 9346K->7525K(60800K), 0.0052810 secs]
[Full GC 7525K->7477K(60800K), 0.0615190 secs]
精彩评论