grpc / grpc/grpc-dart

Memory growth when grpc-web streaming

Open
#511 3 comments 3 reactions 0 assignees View on GitHub
grpc-web help wanted type-bug
Dominant language
Dart
Stars
892
Forks
288
PR merge metrics
No merged PRs in 30d

Description

I currently have an application that streams frames over grpc to flutter mobile and web clients. When running in mobile, the memory seems stable but when doing it in web it appears the data coming from GRPC never gets garbage collected and memory just continues to grow (until the browser runs out of memory). The entirety of these messages are GC'd when the stream is closed but I need to keep the stream open (live video). Is there a way to release these messages as they are processed? I'm wondering if I'm missing something simple. I know grpc-web is done over http but surely this is possible?

Note: the code I wrote is basically the same between platforms and it uses the GrpcOrGrpcWebClientChannel.

Version information:
url: "https://github.com/grpc/grpc-dart.git"
ref: f23070ee85b41504c73cd9586cbb36b383793008
version: "3.0.1-dev"

## Repro steps

1. Have a GRPC server capable of streaming data to a client
2. Create a GrpcOrGrpcWebClientChannel (running on web)
3. Call getStream on it
4. Add a listener to process data

Expected result: Data is garbage collected after being processed

Actual result: Data sticks around and causes memory to grow until out of memory.

## Details

Memory from Mobile (looks reasonable)
![image](https://user-images.githubusercontent.com/2095647/128104138-41f51d4c-1ac9-4bb8-9c90-1d7d51407c11.png)

Memory from Web (constantly increasing)
![image](https://user-images.githubusercontent.com/2095647/128104224-a730bbf1-059d-4334-9bf4-c5bd61c5d210.png)

Contributor guide

Open the contributing guide

Research direction

Start with GrpcOrGrpcWebClientChannel and the getStream path described in the reproduction steps, comparing its web behavior with mobile. Investigate why processed streaming messages remain retained during an open stream. Done means a long-lived grpc-web stream no longer causes unbounded memory growth while messages are processed.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
api, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.