I have a monorail application using Windsor in production and have
noticed a persistent memory issue in our w3wp.exe process for the
application.

I have reviewed the following posts:
http://groups.google.com/group/castle-project-users/browse_thread/thread/bc09194c70e3cecf/f1d874adfc72bdc0?lnk=gst&q=%22memory+leak%22#f1d874adfc72bdc0

http://groups.google.com/group/castle-project-users/browse_thread/thread/a14320c323be7cd0/79e16c568c6996db?lnk=gst&q=%22memory+leak%22#79e16c568c6996db

http://groups.google.com/group/castle-project-users/browse_thread/thread/fff0e03ac2376a6/2d17ed6ee64f9780?lnk=gst&q=%22memory+leak%22#2d17ed6ee64f9780

and found they were either unrelated or their fixes were ineffective.

The service does not have a high load but is usually up 24/7.  The
memory usage does not drop over the weekend (when usage drops to
almost 0) so I don’t think it is session related.

Over the course of several days/weeks, it is easy for the memory usage
to grow to the single digit gigabytes.

I have been using a Selenium script to "stress" the application using
the following process:
   Go to the log in page.
   Log in.
   Open a dialog using ajax.
   Click a link to navigate to a new page.
   Log out.

It then loops over this 200 times.

>From the memory usage, it is clear when garbage collection happens,
but the memory usage after each garbage collection rises over time.

The dialog has a view component that inherits from the smart grid
component.  There are numerous simple view components on all of the
screens.

The system uses SOA for almost all data access, so there is no
nHibernate or other ORM at this layer.

I've tried NoTrackingReleasePolicy, just to see if that was the issue,
as well as setting the life style for controllers/views to
PerWebRequest instead of the MonorailFacility default of Transient
(although the facility might be overriding this, I'm not sure).
Below is a listing of all code related to the Windsor contain in our
system:


public class GlobalApplication : HttpApplication, IContainerAccessor,
IMonoRailConfigurationEvents, IMonoRailContainerEvents  {
        private static WindsorContainer container;
        …
        protected void Application_Start(object sender, EventArgs e)
         {
                container = new WindsorContainer();
                container.AddFacility("mr", new MonoRailFacility());

                //This was added for testing purposes
                container.Kernel.ReleasePolicy = new NoTrackingReleasePolicy();

                container = WebComponentBuilder.AddRegistrationsTo(container);
                container = TranslatorsBuilder.AddRegistrationsTo(container);
                …
        }

        public IWindsorContainer Container
        {
                get { return container; }
        }

        public void Configure(IMonoRailConfiguration configuration)
        {
                // Configuring ViewEngine
                configuration.ViewEngineConfig.ViewPathRoot = Path.Combine
(AppDomain.CurrentDomain.BaseDirectory, "Views");
                configuration.ViewEngineConfig.ViewEngines.Add(new
ViewEngineInfo(typeof                           (NVelocityViewEngine), false));

                // Configure JQuery
                
configuration.JSGeneratorConfiguration.AddLibrary("jquery-1.2.6",
typeof                          
(JQueryGenerator)).AddExtension(typeof(CommonJSExtension))
                        .ElementGenerator.AddExtension(typeof
(JQueryElementGenerator)).Done.BrowserValidatorIs(typeof
(JQueryValidator)).SetAsDefault();
        }

        public void Created(IMonoRailContainer monorailContainer)
        {
        }

        public void Initialized(IMonoRailContainer monorailContainer)
        {
                IAjaxProxyGenerator ajaxProxyGenerator = new
JQueryAjaxProxyGenerator();
                
monorailContainer.ServiceInitializer.Initialize(ajaxProxyGenerator,
monorailContainer);
                monorailContainer.AjaxProxyGenerator = ajaxProxyGenerator;
        }
}

public class WebComponentBuilder
{
        public static WindsorContainer AddRegistrationsTo(WindsorContainer
container)
        {
                //Auto register all controllers and view components

                //Configure(reg => reg.LifeStyle.PerWebRequest) added for 
testing
only
                container.Register(AllTypes.FromAssembly(typeof
(HomeController).Assembly).BasedOn<SmartDispatcherController>().Configure
(reg => reg.LifeStyle.PerWebRequest));

                container.Register(AllTypes.FromAssembly(typeof
(GlobalApplication).Assembly).BasedOn<ViewComponent>().Configure(reg
=>                      
reg.Named(reg.ServiceType.Name).LifeStyle.PerWebRequest));

                return container;
        }
}

public static WindsorContainer AddRegistrationsTo(WindsorContainer
container)
{
        container.Register(Component.For<ITranslate<ApplicationDto,
ApplicationData>>
().ImplementedBy<ApplicationDtoToApplicationDataTranslator>().Named
("applicationDtoToApplicationDataTranslator"));

        return container;
}

Web.Config (I took a lot out that didn't look relevant)
<?xml version="1.0"?>
<configuration>
        <configSections>
                <section name="monorail"
type="Castle.MonoRail.Framework.Configuration.MonoRailSectionHandler,
Castle.MonoRail.Framework"/>
                <sectionGroup name="system.web.extensions"
type="System.Web.Configuration.SystemWebExtensionsSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
                        <sectionGroup name="scripting"
type="System.Web.Configuration.ScriptingSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
                                <section name="scriptResourceHandler"
type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication"/>
                                <sectionGroup name="webServices"
type="System.Web.Configuration.ScriptingWebServicesSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
                                        <section name="jsonSerialization"
type="System.Web.Configuration.ScriptingJsonSerializationSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="Everywhere"/>
                                        <section name="profileService"
type="System.Web.Configuration.ScriptingProfileServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication"/>
                                        <section name="authenticationService"
type="System.Web.Configuration.ScriptingAuthenticationServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication"/>
                                        <section name="roleService"
type="System.Web.Configuration.ScriptingRoleServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication"/>
                                </sectionGroup>
                        </sectionGroup>
                </sectionGroup>
        </configSections>
        <!--
                For more on MonoRail configuration see
                
http://www.castleproject.org/monorail/documentation/v1rc3/index.html
        -->
        <monorail smtpHost="yoursmtphost" useWindsorIntegration="true">
                <controllers>
                        <assembly>Everest.Web</assembly>
                        <assembly>Castle.MonoRail.ViewComponents</assembly>
                </controllers>
        </monorail>
        <system.web>
                <httpHandlers>
                        <add verb="*" path="*.mr"
type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory,
Castle.MonoRail.Framework"/>
                        <!-- block direct user access to template files -->
                        <add verb="*" path="*.vm" 
type="System.Web.HttpForbiddenHandler"/>
                        <add verb="*" path="*.njs" 
type="System.Web.HttpForbiddenHandler"/>
                        <add verb="*" path="*.brail" 
type="System.Web.HttpForbiddenHandler"/
>
                        <add verb="*" path="*.brailjs"
type="System.Web.HttpForbiddenHandler"/>
                        <add verb="*" path="*.st" 
type="System.Web.HttpForbiddenHandler"/>
                        <add verb="*" path="*.xml" 
type="System.Web.HttpForbiddenHandler"/>
                        <remove verb="*" path="*.asmx"/>
                        <add verb="*" path="*.asmx" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
                        <add verb="*" path="*_AppService.axd" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
                        <add verb="GET,HEAD" path="ScriptResource.axd" 
validate="false"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>

                </httpHandlers>

</configuration>


I have some graphs of the memory usage, but it doesn't look like I can
post those here.  If they would help, let me know and I can send them
along (they all look like a saw blade with the valleys trending ever
upwards).
I can’t say for sure that it is Monorail/Windsor related, but I’m not
sure what else it could be.
We noticed the issue in an older version of these frameworks, but just
upgraded them to the latest version:
        Castle.Monorail.Framework.dll - 2.1.0.100
        Castle.Windsor.dll - 2.5.3.0
        Castle.Core.dll - 2.5.2.0
        Castle.DynamicProxy2.dll - 2.1.0.5642

Any help or direction would be greatly appreciated.

Thanks
Sean

-- 
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.

Reply via email to