grpc / grpc/grpc-java

InProcess: client streaming memory leak when retry enabled

Abierto
#8,712 10 comentarios 3 reacciones 1 asignado Asignado a @shivaspeaks Ver en GitHub
bug enhancement
Lenguaje dominante
Java
Estrellas
12.1k
Forks
4k
Merge medio
2 d 17 h
PR fusionados (30 d)
37

Descripción

### What version of gRPC-Java are you using?

1.42.0

### What is your environment?

Linux 5.15.2
openjdk version "11.0.13" 2021-10-19

### What did you expect to see?

No java heap space exception.

### What did you see instead?

`java.lang.OutOfMemoryError: Java heap space`

### Steps to reproduce the bug

We've recently updated our grpc dependency from 1.39.0 to 1.42.0 which now causes an out of memory error in one of our tests.

I've attached a test project that can reproduce the problem.
[grpcheap.zip](https://github.com/grpc/grpc-java/files/7562661/grpcheap.zip)

How to run:

```
mvn clean test -Dgrpc.version=1.39.0 # test runs successfully
mvn clean test -Dgrpc.version=1.42.0 # test fails with OOM
```

Please be aware that the test is run with limited heap size (see pom.xml): `-Xmx64M`

The general idea of the test is this:
Client-side has an `InputStream` that produces ~200mb data. This data of that stream is (lazily) split into ~1mb chunks and these are then streamed to the server.

What happens when I run the test with grpc >1.40 is that I get an OOM when it has sent ~60mb worth of chunks, which obviously is near the `-Xmx` limit. However, what I would expect is that the heap usage would never rise to that level, as after each 1mb chunk has been sent that chunk can be gc'ed. I've also attached a screenshot of visualvm where you can see the heap graph of the test using grpc 1.39.0 vs 1.42.0:

![grpc](https://user-images.githubusercontent.com/574849/142431013-583ee74c-6332-4991-95fd-822f2ffba3b8.png)

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.