Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in Castle.Core proxy generation #16

Closed
sonicmouse opened this issue Jul 2, 2018 · 2 comments
Closed

Memory leak in Castle.Core proxy generation #16

sonicmouse opened this issue Jul 2, 2018 · 2 comments
Assignees
Milestone

Comments

@sonicmouse
Copy link

sonicmouse commented Jul 2, 2018

In the client code, method private static IpcRequest GetRequest(Expression exp, MyInterceptor interceptor) (link)

You are generating a new Castle.Core proxy generator in every request. This should only be done once and statically. So, just simply add this to the top of your file:

private static readonly ProxyGenerator _proxyGenerator;
static IpcServiceClient()
{
    _proxyGenerator = new ProxyGenerator();
}

then in the method above, just use the static _proxyGenerator instead of generating a new one each time.

TInterface proxy = _proxyGenerator.CreateInterfaceProxyWithoutTarget<TInterface>(interceptor);
Delegate @delegate = lamdaExp.Compile();
@delegate.DynamicInvoke(proxy);

I was making thousands of requests per minute and just watched the memory climb and climb... now, with the fix, it doesn't climb at all... AND is much faster!

thanks...

@jacqueskang
Copy link
Owner

Thanks, I'll integreate for next release

@jacqueskang jacqueskang self-assigned this Jul 13, 2018
jacqueskang pushed a commit that referenced this issue Jul 13, 2018
jacqueskang added a commit that referenced this issue Jul 13, 2018
@jacqueskang
Copy link
Owner

Resolved in v1.0.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants