]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Builtins and JavaModule SCL modules may leak memory 35/735/4
authorjsimomaa <jani.simomaa@gmail.com>
Thu, 20 Jul 2017 13:17:36 +0000 (16:17 +0300)
committerJani Simomaa <jani.simomaa@semantum.fi>
Sun, 23 Jul 2017 07:29:54 +0000 (10:29 +0300)
Still needs a better fix though

refs #7352

Change-Id: I9206376349bedf4a92763094b2859230dbf69f77

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/JavaModule.java
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java

index 334cb4560cc488e2ae2a9101dc245f64c0f10c04..4d48d1e9cb1442ec5854728b2b83518e985b859b 100644 (file)
@@ -9,7 +9,6 @@ import org.simantics.scl.compiler.common.precedence.Associativity;
 import org.simantics.scl.compiler.common.precedence.Precedence;
 import org.simantics.scl.compiler.constants.BooleanConstant;
 import org.simantics.scl.compiler.constants.Constant;
-import org.simantics.scl.compiler.constants.JavaConstructor;
 import org.simantics.scl.compiler.constants.JavaStaticField;
 import org.simantics.scl.compiler.constants.JavaStaticMethod;
 import org.simantics.scl.compiler.constants.NoRepConstant;
@@ -53,10 +52,10 @@ import org.simantics.scl.runtime.profiling.BranchPoint;
 
 public class Builtins extends ConcreteModule {
 
-    public static SCLValue[] TUPLE_CONSTRUCTORS = new SCLValue[Constants.MAX_TUPLE_LENGTH+1];
-    public static SCLValue[] LIST_CONSTRUCTORS = new SCLValue[Constants.MAX_LIST_LITERAL_LENGTH+1];
+    public static final SCLValue[] TUPLE_CONSTRUCTORS = new SCLValue[Constants.MAX_TUPLE_LENGTH+1];
+    public static final SCLValue[] LIST_CONSTRUCTORS = new SCLValue[Constants.MAX_LIST_LITERAL_LENGTH+1];
     
-    public static final Builtins INSTANCE = new Builtins();       
+    public static Builtins INSTANCE = new Builtins();
     
     public static SCLValue Nothing;
     public static SCLValue Just;
@@ -363,4 +362,8 @@ public class Builtins extends ConcreteModule {
         return documentation;
     }
 
+       public static void flush() {
+               INSTANCE = new Builtins();
+       }
+
 }
index e412a11689f708e3dd27679a82d468173743a9d8..aeec9a35be73a7485597060e07071c874db3d470 100644 (file)
@@ -23,7 +23,7 @@ import org.simantics.scl.compiler.types.kinds.Kinds;
 
 public class JavaModule extends ConcreteModule {
 
-    public static final JavaModule INSTANCE = new JavaModule();
+    public static JavaModule INSTANCE = new JavaModule();
     
     public static final String MODULE_NAME = "JavaBuiltin";
 
@@ -147,6 +147,9 @@ public class JavaModule extends ConcreteModule {
             result = new EApplyType(result, var);
         return result;
     }
-    
+
+    public static void flush() {
+       INSTANCE = new JavaModule();
+    }
 }
 
index e1eb08baf0321c200af4d79b06034ceb5b4469b3..0c0d8682a5706688c6031f8f68698823390ccb89 100644 (file)
@@ -11,9 +11,9 @@ import java.util.Set;
 
 import org.simantics.scl.compiler.commands.CommandSession;
 import org.simantics.scl.compiler.commands.TestScriptExecutor;
+import org.simantics.scl.compiler.elaboration.java.Builtins;
+import org.simantics.scl.compiler.elaboration.java.JavaModule;
 import org.simantics.scl.compiler.module.coverage.CombinedCoverage;
-import org.simantics.scl.compiler.module.options.ModuleCompilationOptions;
-import org.simantics.scl.compiler.module.options.ModuleCompilationOptionsAdvisor;
 import org.simantics.scl.compiler.module.repository.ModuleRepository;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
@@ -140,6 +140,8 @@ public class ModelledSTSTest {
         } finally {
             // remember to flush this repository
             repo.flush();
+            Builtins.flush();
+            JavaModule.flush();
         }
     }