-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Labels
kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.triage/acceptedIndicates an issue or PR is ready to be actively worked on.Indicates an issue or PR is ready to be actively worked on.
Description
When calling following code multiple times with different lists of assemblies:
var archLoader = new ArchLoader();
archLoader = archLoader.LoadAssembliesIncludingDependencies(assemblies);
ArchUnitNET.Domain.Architecture architectureUnderTest = archLoader.Build();
somewhen an OutOfMemoryException is thrown.
The reason is that the internal static cache (ArchitectureCache) grows until there is no memory.
The problem can be avoided by following HACK, (which is no real option):
private static void ClearInternalCache(ArchLoader archLoader)
{
System.Reflection.FieldInfo archBuilderField = archLoader.GetType().GetField("_archBuilder", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
object archBuilderValue = archBuilderField.GetValue(archLoader);
System.Reflection.FieldInfo architectureCacheField = archBuilderValue.GetType().GetField("_architectureCache", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
object architectureCacheValue = architectureCacheField.GetValue(archBuilderValue);
System.Reflection.MethodInfo clearMethod = architectureCacheValue.GetType().GetMethod("Clear");
clearMethod.Invoke(architectureCacheValue, null);
}
Therefore the cache mechanism shall be extended to be configurable or to be turned off so that OutOfMemoryException can be avoided.
Metadata
Metadata
Assignees
Labels
kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.triage/acceptedIndicates an issue or PR is ready to be actively worked on.Indicates an issue or PR is ready to be actively worked on.