That is expected and by designYou are creating a new ProxyGenerator all the time A proxy generator is the unit for generating assemblies. As such, your code forces DP to keep creating new assemblies, which never goes away. Use a singleton ProxyGenerator
On Thu, Sep 3, 2009 at 10:49 AM, Koen Janssens <[email protected]> wrote: > > Hi, > > I have an issue with DynamicProxy2, if you create a dynamic proxy > inside a proxy the memory isn't released as it should. In the code > below I work with new ProxyGenerators for every call. When I change it > to a ProxyGenerator singleton, the code works as expected (and is also > much faster). > > Is this a bug or shouldn't you create new ProxyGenerators for every > call by design? > > internal class Program > { > private static void Main(string[] args) > { > var proxyGenerator = new ProxyGenerator(); > var proxy = (TestClass1) > proxyGenerator.CreateClassProxy(typeof > (TestClass1)); > > for (var i = 0; i < 1000; i++) > { > proxy.GetHeavyObject(); > } > Console.WriteLine("Done"); > Console.ReadKey(); > } > } > > public class TestClass1 > { > public virtual byte[] GetHeavyObject() > { > var proxyGenerator = new ProxyGenerator(); > var proxy = > (TestClass2)proxyGenerator.CreateClassProxy(typeof > (TestClass2)); > return proxy.GetHeavyObject(); > } > } > > public class TestClass2 > { > public virtual byte[] GetHeavyObject() > { > return new byte[1024*1024]; > } > } > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
