aspose file tools
The moose likes Testing and the fly likes Detecting memory leak with Junit Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Reply 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
Tools for testing static methods
unit testing for SCJD
Tools for testing static methods
Testing tools
How to automate testing with database/web servers