wood burning stoves 2.0*
The moose likes Testing and the fly likes Detecting memory leak with Junit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Detecting memory leak with Junit" Watch "Detecting memory leak with Junit" New topic
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
    
    5
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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Detecting memory leak with Junit
 
Similar Threads
Testing tools
How to automate testing with database/web servers
Tools for testing static methods
unit testing for SCJD
Tools for testing static methods