cefsharp/CefSharp — pull request #590 by sylvain-hamel (2014-11-11 14:12:53+00:00)
Title: CefRenderProcess process creates too many channels and does not close them

This PR is a re-submission of https://github.com/cefsharp/CefSharp/pull/589 based on `master`. Here is the original description.

===

We found out that if the JavaScript code calls into the host application (via the JS binding) too aggressively (a thousand times in a row), the application hangs.

Although we cannot explain the symptom (the hang itself), we know that it's caused by the fact that the channels created by the renderer are never closed.

A fix would be to close the channel after each usage (after each call to _createBrowserProxyDelegate();) like this:

auto browserProxy = _createBrowserProxyDelegate();
auto clientChannel = ((IClientChannel)browserProxy);
auto result = browserProxy->DoSomeThing();
clientChannel->Close();
return result;
This fix works, however, we also realized that this is creating a new channel for each call from the CefRenderProcess to the host application. This is unnecessary and slows down things a lot. With a channel-per-call, making 10,000 calls takes about 10 seconds. With a channel-per-browser, making 10,000 calls takes about 4.5 seconds.

Therefore, this change includes:

Modifications to use only one channel
Modifications to the sample application to add a load test
You can try it first with no modifications to the code. It always hangs before it reaches 1000 calls.
Then you can try it with the correct disposal of the channel. Now it finishes.
Then you can test it with the final code. Now it finishes fast.

===