Memory leak of TString.tensorOf(Shape shape, DataBuffer<String> data)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- java
- Área
- machine-learning
Línea de trabajo
Empieza ejecutando la reproducción de Java proporcionada en torno a TString.tensorOf(Shape, DataBuffer) y DataBuffers.ofObjects(result); después, inspecciona cómo TString.close() libera los recursos. Compara el comportamiento de la memoria en los casos de 4, 8192 y 65536 iteraciones. Se considera terminado cuando las instancias de TString creadas y cerradas repetidamente ya no provocan que el uso de memoria crezca de forma inesperada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
Yes - OS Platform and Distribution (e.g., Linux Ubuntu 16.04 x86_64):
macOS 11.5.2 - TensorFlow installed from (source or binary):
Binary - TensorFlow version (use command below):
2.5 - Java version (i.e., the output of
java -version):Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode) - Java command line flags (e.g., GC parameters):
-ea - Python version (if transferring a model trained in Python):
3.7 - Bazel version (if compiling from source): N/A
- GCC/Compiler version (if compiling from source): N/A
- CUDA/cuDNN version: N/A
- GPU model and memory: N/A
- Tensorflow Java version:
0.3.2
Describe the current behavior
When I create and destroy TString instances repeatedly in a for loop, memory usage grows. In my production environment, where a TF model is served by a java service, it would cause memory usage alert after processing certain amount of requests.
Describe the expected behavior
Memory usage should not grow since created TString instances are closed in each iteration.
Code to reproduce the issue
@Test
void testPerformance() throws Exception {
// Some code to load a model but never used it in this test case. Otherwise, the following code would exit randomly. See https://github.com/tensorflow/java/issues/370 .
final String[] result = new String[] {"a", "b", "c", "d", "e", "f", "g", "h", "i", "c", "c", "c"};
for (int i = 0; i < 65536; ++i) {
try (final TString tstring = TString.tensorOf(Shape.of(1, result.length), DataBuffers.ofObjects(result))) {
// this block is empty.
}
}
}
Other info / logs
4 iterations

8192 iterations

65536 iterations

The above are IntelliJ IDEA's memory profiling screenshots. The differences are as following:
- The first was recorded when the
forloop runs 4 iterations (; i < 4; ...). TheTString.tensorOfcalls only use 2% memory of its parent call. - The second wass recorded when the
forloop runs 8192 iterations (; i < 8192; ...). TheTString.tensorOfcalls use 49.05% memory of its parent call. - The third was recorded when the
forloop runs 65536 iterations (; i < 65536; ...). TheTString.tensorOfcalls use up to 83.56% memory of its parent call.
- Lenguaje dominante
- Java
- Estrellas
- 928
- Forks
- 227
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de tensorflow/java
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
tensorflow/java#653 · 1 comentario · 4 reacciones ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
tensorflow/java#621 · 4 comentarios ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
tensorflow/java#617 · 3 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
tensorflow/java#615 · 1 comentario ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
tensorflow/java#614 · 1 comentario ·
Todos los issues de tensorflow/java
Issues similares
-
bug untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
opensearch-project/ml-commons#5094 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
emitter:client:csharp feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
affects/8.10 affects/8.9 component/clients kind/bug likelihood/mid severity/mid
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Abiertobug frontend maui-pilot
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100