[gbrainy] Fixes + memory usage optimization



commit ad9b933b8641e246e95ebdfaf638c574019cbe42
Author: Jordi Mas <jmas softcatala org>
Date:   Mon Jul 19 20:24:00 2010 +0200

    Fixes + memory usage optimization

 src/Core/Core.csproj                |    1 +
 src/Core/Main/Xml/CodeEvaluation.cs |    5 +++--
 src/Core/Main/Xml/GameXml.cs        |   17 ++++++++++++-----
 src/Core/Main/Xml/GameXmlFactory.cs |    1 +
 4 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index 5aa8a73..2267a3f 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -96,6 +96,7 @@
     <Compile Include="Platform\Unix.cs" />
     <Compile Include="Main\Xml\CodeEvaluation.cs" />
     <Compile Include="Main\GameAnswerCheckAttributes.cs" />
+    <Compile Include="Main\GameDifficulty.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>
diff --git a/src/Core/Main/Xml/CodeEvaluation.cs b/src/Core/Main/Xml/CodeEvaluation.cs
index 289108c..593aac1 100644
--- a/src/Core/Main/Xml/CodeEvaluation.cs
+++ b/src/Core/Main/Xml/CodeEvaluation.cs
@@ -46,8 +46,9 @@ namespace gbrainy.Core.Main.Xml
 
 				// Infrastructure for the user available
 				eval = "Random random = new Random ();\n";
-				Mono.CSharp.Evaluator.Run (eval);
-				Mono.CSharp.Evaluator.Run (code);
+
+				// As Mono 2.4.4 this call is killing in terms of memory leaking
+				Mono.CSharp.Evaluator.Run (eval + code);
 			}
 
 			catch (Exception e)
diff --git a/src/Core/Main/Xml/GameXml.cs b/src/Core/Main/Xml/GameXml.cs
index 2ca4731..2036028 100644
--- a/src/Core/Main/Xml/GameXml.cs
+++ b/src/Core/Main/Xml/GameXml.cs
@@ -154,11 +154,18 @@ namespace gbrainy.Core.Main.Xml
 				// Evaluate code
 				CodeEvaluation.EvaluateVariables (variables);
 
-				if (String.IsNullOrEmpty (localizable_question.Value) == false)
-					localizable_question.ValueComputed = Int32.Parse (CodeEvaluation.ReplaceVariables (localizable_question.Value));
+				try {
 
-				if (localizable_rationale != null && String.IsNullOrEmpty (localizable_rationale.Value) == false)
-					localizable_rationale.ValueComputed = Int32.Parse (CodeEvaluation.ReplaceVariables (localizable_rationale.Value));
+					if (String.IsNullOrEmpty (localizable_question.Value) == false)
+						localizable_question.ValueComputed = Int32.Parse (CodeEvaluation.ReplaceVariables (localizable_question.Value));
+
+					if (localizable_rationale != null && String.IsNullOrEmpty (localizable_rationale.Value) == false)
+						localizable_rationale.ValueComputed = Int32.Parse (CodeEvaluation.ReplaceVariables (localizable_rationale.Value));
+				}
+				catch (Exception e)
+				{
+					Console.WriteLine ("GameXml.Initialize {0}", e);
+				}
 			}
 
 			if (variants && game.Variants[current.Variant].Question != null)
diff --git a/src/Core/Main/Xml/GameXmlFactory.cs b/src/Core/Main/Xml/GameXmlFactory.cs
index a4e8d02..c01bd3a 100644
--- a/src/Core/Main/Xml/GameXmlFactory.cs
+++ b/src/Core/Main/Xml/GameXmlFactory.cs
@@ -311,6 +311,7 @@ namespace gbrainy.Core.Main.Xml
 				}
 
 				reader.Close ();
+				myStream.Dispose ();
 				read = true;
 
 				GameXml.Definitions = games;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]