Comments (6)
Can you try 22.5.1-develop-39
?
from wampsharp.
Thanks, have tied it locally. It seems AsyncLocalRpcOperation.InnerInvokeAsync
is awaiting the task to finish internally and doing the cleanup when CallResult
is called. However at that stage, in the outer call at WampCallee.InvocationPattern
the invocationData may or may not have been added into the mInvocations
. It depends on which of the two finish first: the inner invocation task finishes or WampCallee.InvocationPattern
. So it may still leaks in this situation below:
Proxy interface:
public interface IEchoService
{
[WampProcedure("com.test.echo")]
Task<string> Echo(string message, CancellationToken cancellationToken);
}
This will still leak:
public class EchoService : IEchoService
{
public async Task<string> Echo(string message, CancellationToken cancellationToken)
{
return await Task.FromResult(message);
}
}
or
public Task<string> Echo(string message, CancellationToken cancellationToken)
{
Thread.Sleep(100); // anything takes some time but synchronously.
return Task.FromResult(message);
}
But this will not:
public class EchoService : IEchoService
{
public async Task<string> Echo(string message, CancellationToken cancellationToken)
{
await Task.Delay(10, cancellationToken); //note this delay here.
return await Task.FromResult(message);
}
}
I am thinking if we could somehow create the CancellationTokenSourceInvocation
in WampCallee.InvocationPattern
and save it into mInvocations
, then start the real invocation and pass in the CancellationTokenSourceInvocation
to hook up the cancellation. Opinions?
from wampsharp.
After some try, I have got something like this on my fork branch. You can try run the LeakTestOnCancellableCalls
and use dotMemory to see the leak is stopped now. Please see what you think about it.
from wampsharp.
@bigbearzhu thanks for working on this and for your contribution! Unfortunately, it seems like your solution breaks api (methods no longer return IWampCancellableInvocation
). I fixed this issue differently by adding a property IsInvocationCompleted
to IWampCancellableInvocation
that checks whether the invocation has been completed, and in that case, I remove the invocation from the dictionary. Can you please try 22.5.1-develop-41
and let me know if the problem is solved?
Thanks!
Elad
from wampsharp.
Thanks @darkl and sorry for not replying for quite some time. I have checked the change, it seems it would harder to leak now with the IsInvocationCompleted
check. However, because the inner invocation is running in different thread, so there is no guarantee that the inner invocation would always complete or not complete at right spot before the outer WampCallee
doing its IsInvocationComplete
check. I have created some dummy code with a test to show you one scenario that it could still leak. You can run CallerDealerTests.LeakTestOnCancellableCalls
locally to see how it leaks.
This scenario is where inner invocation already passed calling WampCallee.CleanupInvocationData
but somehow only completed after the outer code finished all its IsInvocationCompleted
check.
DotMemory snapshot showing leak:
On our local fork, we have implemented a fix a little bit different as we need a fix urgently for this issue. Feel free to see if it is ok to cherry pick. The main idea of the fix is to move the registration code into the AsyncLocalRpcOperation
so that it is guaranteed to add/clean registrations in right order. Also we rolled back the breaking api changes so that it still returns IWampCancellableInvocation
.
from wampsharp.
Hi @bigbearzhu, I know it has been a long time. I attempted to resolve both of your issues in 23.3.1-develop-45. I would appreciate it if you could test it and tell me if the issues are gone, whenever you find the time.
Thanks,
Elad
from wampsharp.
Related Issues (20)
- How to handle wamp.error.procedure_already_exists when callee reconnects? HOT 4
- Cache fallback layer to RPC call HOT 1
- How to limit the websocket frame size? HOT 16
- Getting query string parameters with asp.net core. HOT 4
- Request to upgrade to .net 5.1 to fix Websocket issues HOT 2
- Modify WampTopics at Runtime? HOT 4
- Add inner exception in ConvertExceptionToRuntimeException HOT 6
- Windows forms app problem HOT 1
- Publishing to topic in .SubscriptionAdded seems to be impossible? HOT 6
- Hello, I am new to the internet HOT 5
- Event handler leak when cancel an invocation
- Possible to have different types for IProgress<T> and call result in reflection based callee? HOT 10
- How do I get the IP of a client in the session created event on the router? HOT 2
- Progress reporting broken for async operations without a return value HOT 2
- High amount of memory usage from ImmutableList<Int64> HOT 1
- Connection Error Issues HOT 1
- Unhandled terminating exception due to async void HOT 6
- Subscriptions don't work after reconnection. How to handle `onError` with Reflection-based subscriber? HOT 8
- Unable to open channel, WebAssembly, client-side code HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wampsharp.