Sunday, January 3, 2010

Memory Leak Hunt: Aftermath

Q: How much memory does DZ need to run?

A: Within JVM, less than 6MB of heap memory and about 19MB of non-heap, total 25MB - that is with all the features turned on, including JMX and console. Take a look at the picture below.

-Xms4m -Xmx4m

At the same time, JVM takes 177MB virtual memory, 57MB resident, and 10MB shared.

Q: How are you planning to prevent memory leaks in the future?

A: Starting with the next release (3.3.2), DZ JVM will be artificially constrained (-Xms4m -Xmx4m) to make sure that if it blows out of memory, it does it very fast and the leak can be identified and reported immediately.

Q: Will it affect system performance?

A: A little bit, you probably shouldn't care. Garbage collection will be happening once every few minutes instead of once every few hours. After you've ran DZ for a few hours (a day for most paranoid) in minimal configuration, you can safely remove the restriction - instructions will be provided within dz-runner script. Keep in mind, though, that amount of memory that JVM is taking out of the system may be higher if you do that, now, that may affect the system performance.

Q: How did you find the leak?

A: It was a trivial sequence of jmap and jhat runs (details at Monitoring and Managing Java SE 6 Platform Applications). In addition, some small and frequent memory allocations in OWAPI were replaced with local variables, to reduce garbage collection chatter.

Q: You're saying the leak is gone, but I keep getting OutOfMemoryException!

A: Possible. Leak free status was verified for DZ core, 1-Wire sensor driver, and Parallax servo controller driver running on Sun's JDK 1.6.0_17 under Ubuntu 9.10. First thing you need to do is to submit a detailed report including your hardware and platform details. jmap file (see the above link) right after the start and some time before the OutOfMemoryException will be much appreciated.

No comments:

Post a Comment