| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent af394ee commit b0c68e6
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,8 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. | |||
| 27 | 27 | ||
| 28 | 28 | ### Fixed | |
| 29 | 29 | ||
| 30 | + - Fixed secondary PythonEngine.Initialize call, all sensitive static variables now reseted. | ||
| 31 | + This is a hidden bug. Once python cleaning up enough memory, objects from previous engine run becomes corrupted. | ||
| 30 | 32 | - Fixed Visual Studio 2017 compat ([#434][i434]) for setup.py | |
| 31 | 33 | - Fixed crashes when integrating pythonnet in Unity3d ([#714][i714]), | |
| 32 | 34 | related to unloading the Application Domain | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,14 +24,14 @@ internal class AssemblyManager | |||
| 24 | 24 | // than it can end up referring to assemblies that are already unloaded (default behavior after unload appDomain - | |
| 25 | 25 | // unless LoaderOptimization.MultiDomain is used); | |
| 26 | 26 | // So for multidomain support it is better to have the dict. recreated for each app-domain initialization | |
| 27 | - private static ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>> namespaces; | ||
| 28 | - | ||
| 27 | + private static ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>> namespaces = | ||
| 28 | + new ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>>(); | ||
| 29 | 29 | //private static Dictionary<string, Dictionary<string, string>> generics; | |
| 30 | 30 | private static AssemblyLoadEventHandler lhandler; | |
| 31 | 31 | private static ResolveEventHandler rhandler; | |
| 32 | 32 | ||
| 33 | 33 | // updated only under GIL? | |
| 34 | - private static Dictionary<string, int> probed; | ||
| 34 | + private static Dictionary<string, int> probed = new Dictionary<string, int>(32); | ||
| 35 | 35 | ||
| 36 | 36 | // modified from event handlers below, potentially triggered from different .NET threads | |
| 37 | 37 | private static ConcurrentQueue<Assembly> assemblies; | |
@@ -48,10 +48,7 @@ private AssemblyManager() | |||
| 48 | 48 | /// </summary> | |
| 49 | 49 | internal static void Initialize() | |
| 50 | 50 | { | |
| 51 | - namespaces = new ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>>(); | ||
| 52 | - probed = new Dictionary<string, int>(32); | ||
| 53 | - //generics = new Dictionary<string, Dictionary<string, string>>(); | ||
| 54 | - assemblies = new ConcurrentQueue<Assembly>(); | ||
| 51 | + assemblies = new AssemblyList(16); | ||
| 55 | 52 | pypath = new List<string>(16); | |
| 56 | 53 | ||
| 57 | 54 | AppDomain domain = AppDomain.CurrentDomain; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,9 @@ | |||
| 1 | - using System; | ||
| 1 | + using System; | ||
| 2 | 2 | using System.Collections.Generic; | |
| 3 | 3 | using System.Linq; | |
| 4 | 4 | using System.Reflection; | |
| 5 | 5 | using System.Reflection.Emit; | |
| 6 | + using System.Resources; | ||
| 6 | 7 | using System.Runtime.InteropServices; | |
| 7 | 8 | using System.Threading.Tasks; | |
| 8 | 9 | ||
@@ -32,6 +33,12 @@ static ClassDerivedObject() | |||
| 32 | 33 | moduleBuilders = new Dictionary<Tuple<string, string>, ModuleBuilder>(); | |
| 33 | 34 | } | |
| 34 | 35 | ||
| 36 | + public static void Reset() | ||
| 37 | + { | ||
| 38 | + assemblyBuilders = new Dictionary<string, AssemblyBuilder>(); | ||
| 39 | + moduleBuilders = new Dictionary<Tuple<string, string>, ModuleBuilder>(); | ||
| 40 | + } | ||
| 41 | + | ||
| 35 | 42 | internal ClassDerivedObject(Type tp) : base(tp) | |
| 36 | 43 | { | |
| 37 | 44 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,11 @@ static ClassManager() | |||
| 34 | 34 | dtype = typeof(MulticastDelegate); | |
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | + public static void Reset() | ||
| 38 | + { | ||
| 39 | + cache = new Dictionary<Type, ClassBase>(128); | ||
| 40 | + } | ||
| 41 | + | ||
| 37 | 42 | /// <summary> | |
| 38 | 43 | /// Return the ClassBase-derived instance that implements a particular | |
| 39 | 44 | /// reflected managed type, creating it if it doesn't yet exist. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | 1 | using System; | |
| 2 | 2 | using System.Collections.Generic; | |
| 3 | + using System.Resources; | ||
| 3 | 4 | ||
| 4 | 5 | namespace Python.Runtime | |
| 5 | 6 | { | |
@@ -20,6 +21,11 @@ static GenericUtil() | |||
| 20 | 21 | mapping = new Dictionary<string, Dictionary<string, List<string>>>(); | |
| 21 | 22 | } | |
| 22 | 23 | ||
| 24 | + public static void Reset() | ||
| 25 | + { | ||
| 26 | + mapping = new Dictionary<string, Dictionary<string, List<string>>>(); | ||
| 27 | + } | ||
| 28 | + | ||
| 23 | 29 | /// <summary> | |
| 24 | 30 | /// Register a generic type that appears in a given namespace. | |
| 25 | 31 | /// </summary> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -335,6 +335,17 @@ public CLRModule() : base("clr") | |||
| 335 | 335 | } | |
| 336 | 336 | } | |
| 337 | 337 | ||
| 338 | + public static void Reset() | ||
| 339 | + { | ||
| 340 | + hacked = false; | ||
| 341 | + interactive_preload = true; | ||
| 342 | + preload = false; | ||
| 343 | + | ||
| 344 | + // XXX Test performance of new features // | ||
| 345 | + _SuppressDocs = false; | ||
| 346 | + _SuppressOverloads = false; | ||
| 347 | + } | ||
| 348 | + | ||
| 338 | 349 | /// <summary> | |
| 339 | 350 | /// The initializing of the preload hook has to happen as late as | |
| 340 | 351 | /// possible since sys.ps1 is created after the CLR module is | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -537,10 +537,15 @@ public void Dispose() | |||
| 537 | 537 | ||
| 538 | 538 | public class PyScopeManager | |
| 539 | 539 | { | |
| 540 | - public readonly static PyScopeManager Global = new PyScopeManager(); | ||
| 540 | + public static PyScopeManager Global; | ||
| 541 | 541 | ||
| 542 | 542 | private Dictionary<string, PyScope> NamedScopes = new Dictionary<string, PyScope>(); | |
| 543 | 543 | ||
| 544 | + internal static void Reset() | ||
| 545 | + { | ||
| 546 | + Global = new PyScopeManager(); | ||
| 547 | + } | ||
| 548 | + | ||
| 544 | 549 | internal PyScope NewScope(string name) | |
| 545 | 550 | { | |
| 546 | 551 | if (name == null) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -281,6 +281,13 @@ internal static void Initialize() | |||
| 281 | 281 | PyEval_InitThreads(); | |
| 282 | 282 | } | |
| 283 | 283 | ||
| 284 | + CLRModule.Reset(); | ||
| 285 | + GenericUtil.Reset(); | ||
| 286 | + PyScopeManager.Reset(); | ||
| 287 | + ClassManager.Reset(); | ||
| 288 | + ClassDerivedObject.Reset(); | ||
| 289 | + TypeManager.Reset(); | ||
| 290 | + | ||
| 284 | 291 | IntPtr op; | |
| 285 | 292 | IntPtr dict; | |
| 286 | 293 | if (IsPython3) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,10 @@ static TypeManager() | |||
| 21 | 21 | cache = new Dictionary<Type, IntPtr>(128); | |
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | + public static void Reset() | ||
| 25 | + { | ||
| 26 | + cache = new Dictionary<Type, IntPtr>(128); | ||
| 27 | + } | ||
| 24 | 28 | ||
| 25 | 29 | /// <summary> | |
| 26 | 30 | /// Given a managed Type derived from ExtensionType, get the handle to | |
| Back | FazBrowse Home | New Git URL |
0 commit comments