Fix memory leak by disposing a classloader. The real issue though is located in TypeInfoParser, that has WeakHashMap with values referencing keys.
This commit is contained in:
@@ -91,10 +91,14 @@ public abstract class CodegenTestCase extends JetLiteFixture {
|
||||
ClassFileFactory codegens = generateClassesInFile();
|
||||
GeneratedClassLoader loader = new GeneratedClassLoader(codegens);
|
||||
|
||||
String fqName = NamespaceCodegen.getJVMClassName(JetPsiUtil.getFQName(myFile), true).replace("/", ".");
|
||||
Class<?> namespaceClass = loader.loadClass(fqName);
|
||||
Method method = namespaceClass.getMethod("box");
|
||||
return (String) method.invoke(null);
|
||||
try {
|
||||
String fqName = NamespaceCodegen.getJVMClassName(JetPsiUtil.getFQName(myFile), true).replace("/", ".");
|
||||
Class<?> namespaceClass = loader.loadClass(fqName);
|
||||
Method method = namespaceClass.getMethod("box");
|
||||
return (String) method.invoke(null);
|
||||
} finally {
|
||||
loader.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
protected String generateToText() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.local.CoreLocalFileSystem;
|
||||
import gnu.trove.THashSet;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestResult;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.jet.compiler.CompileSession;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
@@ -74,13 +75,19 @@ public class TestlibTest extends CodegenTestCase {
|
||||
|
||||
ClassFileFactory classFileFactory = session.generate();
|
||||
|
||||
GeneratedClassLoader loader = new GeneratedClassLoader(
|
||||
final GeneratedClassLoader loader = new GeneratedClassLoader(
|
||||
classFileFactory,
|
||||
new URLClassLoader(new URL[]{ForTestCompileStdlib.stdlibJarForTests().toURI().toURL(), junitJar.toURI().toURL()},
|
||||
TestCase.class.getClassLoader()));
|
||||
|
||||
JetTypeMapper typeMapper = new JetTypeMapper(classFileFactory.state.getStandardLibrary(), session.getMyBindingContext());
|
||||
TestSuite suite = new TestSuite("StandardLibrary");
|
||||
TestSuite suite = new TestSuite("StandardLibrary") {
|
||||
@Override
|
||||
public void run(TestResult result) {
|
||||
super.run(result);
|
||||
loader.dispose();
|
||||
}
|
||||
};
|
||||
try {
|
||||
for(JetFile jetFile : session.getSourceFileNamespaces()) {
|
||||
for(JetDeclaration decl : jetFile.getDeclarations()) {
|
||||
|
||||
Reference in New Issue
Block a user