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: github.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:97b2fe10-40a6-f50c-d0ea-cd754771d9ce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6D2:CDF29:78B84:AAB3B:696A6523 |
| html-safe-nonce | 7ac47bcfda2bf0c549abc55c307548699a2e472f6122d5397364230b6accbc92 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkQyOkNERjI5Ojc4Qjg0OkFBQjNCOjY5NkE2NTIzIiwidmlzaXRvcl9pZCI6IjMwNzEzMDQ4OTQzNjI4MzgzMDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c830501a7cde94b325d81231704dfe3f9b9b6b51374b00b32c8cc6d623d5c47c |
| 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 | 9b7735a184970dd9333b2cbe036c8f3c0a9108c64aaa93827c5a64fc70993392 |
| 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 | 87cbd411c2982752221b5751d583a515b23bf5fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width