Revision: 251
http://structuremap.svn.sourceforge.net/structuremap/?rev=251&view=rev
Author: cmyers
Date: 2009-06-26 14:34:44 +0000 (Fri, 26 Jun 2009)
Log Message:
-----------
Fixed a memory leak that would manifest when using nested containers (whether dynamic assemblies needed generating or not, PluginCache would create/compile/load an empty assembly every time a new container was created). Repeated calls to a nested container would result in an eventual out of memory situation.
Modified Paths:
--------------
trunk/Source/StructureMap/Graph/PluginCache.cs
Modified: trunk/Source/StructureMap/Graph/PluginCache.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginCache.cs 2009-06-12 20:13:34 UTC (rev 250)
+++ trunk/Source/StructureMap/Graph/PluginCache.cs 2009-06-26 14:34:44 UTC (rev 251)
@@ -64,6 +64,15 @@
private static void createAndStoreBuilders(IEnumerable<Plugin> plugins)
{
+ // If this is a nested container and there are no new plugins,
+ // we don't need to create the InstanceBuilderAssembly
+ // This was causing OutOfMemoryExceptions when using nested containers
+ // repeatedly (i.e. every web request in a web app)
+ if (plugins == null || plugins.Count() == 0) return;
+
+ //NOTE: Calling 'Compile()' on a DynamicAssembly will actually
+ // compile it as a file on the disk and load it into the AppDomain.
+ // If you call it repeatedly, you will eventually run out of memory
var assembly = new InstanceBuilderAssembly(plugins);
assembly.Compile().ForEach(b => _builders[b.PluggedType] = b);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|