-
Notifications
You must be signed in to change notification settings - Fork 132
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 @protobuf-ts/grpc-transport #107
Comments
Great feedback, thanks. Closing the client after each request plugs the memory leak, but I think this doesn't go in the right direction. I am pretty sure that @grpc/grpc-js will keep connections alive (to save expensive TLS handshakes) until you close a channel (by client.close()). At least that is what I would expect from a gRPC client. So the best way forward seems to be to create the client once in the transport (fixing the memory leak, allowing connection re-use) and expose client.close() with a close() method on the transport. There is a minor problem with that: We accept |
@timostamm since I cannot ask you on ETA for this, can I ask you if there is a temporary workaround? In my SPA (single-page-app) I'm not closing/destroying services once opened (with So I think I'm in full memory leak, right? (I don't know how to measure it.) |
@frederikhors No, you are not affected. This is about the gRPC implementation, but your SPA uses gRPC-web. |
@timostamm I agree that the solution with creating I've submitted a PR with partial implementation of this approach (without exposing I've also rebased the demo branch on top of the fix: master:
fix:
let me know if there are any changes you would like me to make. |
@grpc/grpc-js
Client is being created on every call and never disposed after.Demo of the issue can be found here
Example of 2 clients running 1000 unary calls and reporting memory usage after:
make
inpackages/example-node-grpc-server/
to start the servermake
inpackages/example-node-grpc-client/
to see correct memory usagemake
inpackages/example-node-grpc-transport-client/
to see clients not being garbage collectedThe solution would be to either close the client after request, or create it once in GrpcTransport constructor and then reuse.
The text was updated successfully, but these errors were encountered: