| Author |
Detecting memory leak with Junit
|
Ali Ekber
Ranch Hand
Joined: Jun 12, 2005
Posts: 41
|
|
|
I am new to JUnit and was wondering if JUnit can detect possible memory leaks in a large application. Thx.
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
No, it can't. That is, by itself it can't. Of course you might be able to write a JUnit test that can figure out whether there was a memory leak but then it's not really JUnit doing it... (you could try a very primitive--and somewhat unreliable--analysis with totalMemory() and freeMemory() from the java.lang.Runtime class) Or you could just use a profiling tool that can detect memory leaks. I haven't used one for finding memory leak in a while but at least OptimizeIT and JProbe advertize memory leak detection in their feature lists. JProfiler might also help in locating the leaks.
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
 |
|
|
subject: Detecting memory leak with Junit
|
|
|