[GRADLE-2217] ClassFileExtractionManager causes memory leak in Test task Created: 06/Apr/12  Updated: 04/Jan/13  Resolved: 04/May/12

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-9
Fix Version/s: None

Type: Bug
Reporter: Peter Niederwieser Assignee: Luke Daley
Resolution: Fixed Votes: 0


 Description   

Each Test task seems to have its own TestFramework/TestFrameworkDetector/ClassFileExtractionManager. These objects are kept in memory even after the task has run, causing a memory leak. In a project with 800+ Test tasks, ClassFileExtractionManager retained 350MB heap in total and up to 12MB per instance at the time the OOME occurred. The workaround we used was to null out Test.testFramework in a doLast action.



 Comments   
Comment by Luke Daley [ 10/Apr/12 ]

I've had a quick look, some options in order of easiest to hardest (guessed):

1. Have the test task null out the testFramework object after execution
2. Restructure so that testFramework is not an ivar
3. Reuse a singleton ClassFileExtractionManager across an entire build

#2 will require some juggling to deal with API changes but it's not terrible. #3 is potentially attractive as it may offer a performance increase by not requiring test classes to be extracted from jars for each test execution

Generated at Wed Jun 30 12:15:55 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.