Hi,

 I am trying to find out how to release the memory from a
MarshByRefObject object.
 My c# application is window service.  It gets call from another
window service or remote window clients.
 In the EnumerateWorkflows method, I returns the arraylist of
IWorkflow which is MarshByRefObject.
 If the client invoke 1000 EnumerateWorkflows calls, my window
service memory will grow very large.
 Any suggestions as how my service can release some of the memory?

 THanks,

 Pauline
 -----------
 class WorkflowCollection : MarshalByRefObject, IWorkflowCollection
 {
  public override Object InitializeLifetimeService()
  {
   null;
  }

  public IWorkflow[] EnumerateWorkflows()
  {
   try
   {
   .
   .
   .
    ArrayList workflows = new ArrayList();
    foreach (DataRow row in ds.Tables
["workflow"].Rows )
    {
     IWorkflow newWorkflow = new Workflow
(...)  // IWorkflow is MarshByRefObject
     workflows.Add(newWorkflow);
    }
    return (IWorkflow[]) workflows.ToArray
(typeof(IWorkflow));
   }
   catch (Exception e)
   {
    log.ErrWriteLine(string.Format
("WorkflowCollection:EnumerateWorkflow(): Caught {0}: {1}\n{2}",
     e.GetType(), e.Message,
e.StackTrace));
    return null;
   }

  }

    }
}

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to