Memory leaks while calls across application domain C#
<p>I have a problem. In my application we have a scripting language. Using this language user can make my application to load an assembly and call any of its function.</p>

<p>So its a question about memory leaks while calling functions from a .Net assembly. We are following below steps:</p>

<p>1  We create a separate application domain.</p>

<p>2  We load the user specified assembly in this separate domain.</p>

<p>3  We have a class <strong>Arg</strong> derived from <strong>MarshalByRefObject</strong>. The arguments that are to be passed to the function of assembly, are represented by this <strong>Arg</strong> class. In other words, we create objects of <strong>Arg (derived from MarshalByRefObject)</strong> corresponding to the parameters to be passed to function of assembly.</p>

<p>4 Then function in assembly is called by passing these objects as parameters.</p>

<p>Now the problem is that even when the function in assembly has been called, these objects are not released. It causes memory leaks.</p>

<p>One thing that I know is that, when an assembly is in separate application domain but in same process, Garbage Collector should collect unused object including that are passed from one application domain to other. But its not happening here.</p>

<p>Can any body tell me if we load assembly in separate app-domain but in same process, how can we free objects (derived from MarshalByRefObject)? Any special way of doing that?</p>

<p>I am sorry, I am not allowed to share even a single line of code. If some body can help me please.</p>
