[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

kh

5/8/2007 12:02:00 PM

Hi. We are using a third-party unmanaged DLL via PInvoke, but we have
discovered that over time the application's process is accumulating memory
and analysis has shown that this is because the unamanaged DLL is aggregating
state between calls.

We do not have control over the third-party DLL so we need to be able to
"unload" it between calls. We have considered creating a hosting process for
the unmanaged DLL and using remoting to make calls to this process,
periodically destroying and recreating the hosting process once we hit some
arbitrary memory threshold. We acknowledge that there is an overhead in doing
this but this should be acceptable in our scenario.

Is this a viable solution, and are there any samples out there?

Many thanks

kh
1 Answer

Obiwan Jacobi

5/11/2007 8:13:00 AM

0

On May 8, 2:02 pm, kh <k...@nospam.nospam> wrote:
> Hi. We are using a third-party unmanaged DLL via PInvoke, but we have
> discovered that over time the application's process is accumulating memory
> and analysis has shown that this is because the unamanaged DLL is aggregating
> state between calls.
>
> We do not have control over the third-party DLL so we need to be able to
> "unload" it between calls. We have considered creating a hosting process for
> the unmanaged DLL and using remoting to make calls to this process,
> periodically destroying and recreating the hosting process once we hit some
> arbitrary memory threshold. We acknowledge that there is an overhead in doing
> this but this should be acceptable in our scenario.
>
> Is this a viable solution, and are there any samples out there?

Because the dll is unmanaged and also uses unmanaged memory, setting
up a seperate AppDomain would get you nothing. To my knowledge the
next best thing is to setup a seperate Win32 process. I'm not aware of
any samples though.

Isn't there a chicken and egg problem hidden in recycling a process?
Once you decide the process needs to be recycled, it can exit itself.
But who is going to start it up again? You might need a process
recycling (NT) service.

Grtx
-Marc