Title: Allocation of 360434219 exceeds 10% of free system memory. · Issue #588 · tensorflow/java · GitHub
Open Graph Title: Allocation of 360434219 exceeds 10% of free system memory. · Issue #588 · tensorflow/java
X Title: Allocation of 360434219 exceeds 10% of free system memory. · Issue #588 · tensorflow/java
Description: 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 (a...
Open Graph Description: 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 i...
X Description: 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 i...
Opengraph URL: https://github.com/tensorflow/java/issues/588
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allocation of 360434219 exceeds 10% of free system memory.","articleBody":"\u003cem\u003ePlease make sure that this is a bug. As per our [GitHub Policy](https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md), we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template\u003c/em\u003e\r\n\r\n**System information**\r\n- Have I written custom code (as opposed to using a stock example script provided in TensorFlow):\r\n- OS Platform and Distribution (e.g., Linux Ubuntu 16.04 x86\\_64): **Linux x86_64 in a Docker cointainer**\r\n- TensorFlow installed from (source or binary):\r\n- TensorFlow version (use command below): **1.0.0-RC.2**\r\n- Java version (i.e., the output of `java -version`): **openjdk version \"21.0.4\"**\r\n- Java command line flags (e.g., GC parameters):\r\n- Python version (if transferring a model trained in Python): **3.9**\r\n- Bazel version (if compiling from source):\r\n- GCC/Compiler version (if compiling from source):\r\n- CUDA/cuDNN version:\r\n- GPU model and memory:\r\n\r\n**Describe the current behavior**\r\nI am using TensorFlow in a Spring Boot application, which exposes an endpoint for NER processing. The TensorFlow model is trained in Python and loaded into the Java application for inference.\r\n\r\nTo optimize performance, I initialize the TensorFlow session once during application startup using a @PostConstruct method and store it in a private field:\r\n\r\n```\r\nprivate Session session;\r\n\r\n@PostConstruct\r\nprivate void initialize() throws IOException {\r\n byte[] bytes = Files.readAllBytes(Paths.get(\"/path/to/model/\"));\r\n Graph graph = new Graph();\r\n graph.importGraphDef(GraphDef.parseFrom(bytes), \"PREFIX\");\r\n session = new Session(graph);\r\n}\r\n```\r\n\r\nThe session is reused in a public method for running predictions:\r\n\r\n```\r\npublic Result predict(String input) {\r\n try (Tensor textTensor = Tensor.of(TINT32.class, ...);\r\n Result result = session.runner()\r\n .feed(\"otherOperationName\", textTensor)\r\n .fetch(\"operationName\")\r\n .run()) {\r\n // Process the result here\r\n }\r\n}\r\n\r\n```\r\n\r\nDuring performance testing, I monitored the heap memory and found no significant issues. However, when the application runs in a Docker container, it crashes after a while, regardless of the memory allocated to the container (even with 120GB of memory). The following warning appears in the logs before the crash:\r\n\r\n`W external/local_tsl//framework/cpu_allocator_impl.cc:83] Allocation of 34891293 exceeds 10% of free system memory.`\r\n\r\nIs it possible that the memory leak is caused by the session being stored in a private field and never explicitly closed, even though all tensors and intermediate results are properly managed (closed) in the predict method?\r\n\r\n**Describe the expected behavior**\r\nThe application should not exhibit memory leaks or crashes when deployed in a Docker container, regardless of memory allocation.\r\n","author":{"url":"https://github.com/icrecescu","@type":"Person","name":"icrecescu"},"datePublished":"2024-11-25T06:25:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/588/java/issues/588"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:50400e51-7192-00ba-8bf2-c37961db1924 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8F50:A2119:1EBFBA4:29A56B9:697081C3 |
| html-safe-nonce | bed354e4c75137d3c85139d859153da3b224559c45494a5ce8c1c066f0aabbc1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjUwOkEyMTE5OjFFQkZCQTQ6MjlBNTZCOTo2OTcwODFDMyIsInZpc2l0b3JfaWQiOiI1MjM1MDY1NzIxMDkwNzY5MzQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7edf8ffb5293658f6c056f4147c20c6ea2060f9fab28802d59a7820ecbbfe38b |
| hovercard-subject-tag | issue:2689346573 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/tensorflow/java/588/issue_layout |
| twitter:image | https://opengraph.githubassets.com/24633f16c5b98bd6b25a1414d18a8ed8be26f25541f48dd8fe27d1c114947a26/tensorflow/java/issues/588 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/24633f16c5b98bd6b25a1414d18a8ed8be26f25541f48dd8fe27d1c114947a26/tensorflow/java/issues/588 |
| og:image:alt | 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 i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | icrecescu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/tensorflow/java git https://github.com/tensorflow/java.git |
| octolytics-dimension-user_id | 15658638 |
| octolytics-dimension-user_login | tensorflow |
| octolytics-dimension-repository_id | 207384523 |
| octolytics-dimension-repository_nwo | tensorflow/java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 207384523 |
| octolytics-dimension-repository_network_root_nwo | tensorflow/java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width