{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19049","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19049/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19049/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19049/events","html_url":"https://github.com/tensorflow/tensorflow/issues/19049","id":319848917,"number":19049,"title":"Memory Leak when tf.Session run on the sliced tensor","user":{"login":"chychen","id":5878561,"avatar_url":"https://avatars3.githubusercontent.com/u/5878561?v=4","gravatar_id":"","url":"https://api.github.com/users/chychen","html_url":"https://github.com/chychen","followers_url":"https://api.github.com/users/chychen/followers","following_url":"https://api.github.com/users/chychen/following{/other_user}","gists_url":"https://api.github.com/users/chychen/gists{/gist_id}","starred_url":"https://api.github.com/users/chychen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chychen/subscriptions","organizations_url":"https://api.github.com/users/chychen/orgs","repos_url":"https://api.github.com/users/chychen/repos","events_url":"https://api.github.com/users/chychen/events{/privacy}","received_events_url":"https://api.github.com/users/chychen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jart","id":49262,"avatar_url":"https://avatars1.githubusercontent.com/u/49262?v=4","gravatar_id":"","url":"https://api.github.com/users/jart","html_url":"https://github.com/jart","followers_url":"https://api.github.com/users/jart/followers","following_url":"https://api.github.com/users/jart/following{/other_user}","gists_url":"https://api.github.com/users/jart/gists{/gist_id}","starred_url":"https://api.github.com/users/jart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jart/subscriptions","organizations_url":"https://api.github.com/users/jart/orgs","repos_url":"https://api.github.com/users/jart/repos","events_url":"https://api.github.com/users/jart/events{/privacy}","received_events_url":"https://api.github.com/users/jart/received_events","type":"User","site_admin":false},"assignees":[{"login":"jart","id":49262,"avatar_url":"https://avatars1.githubusercontent.com/u/49262?v=4","gravatar_id":"","url":"https://api.github.com/users/jart","html_url":"https://github.com/jart","followers_url":"https://api.github.com/users/jart/followers","following_url":"https://api.github.com/users/jart/following{/other_user}","gists_url":"https://api.github.com/users/jart/gists{/gist_id}","starred_url":"https://api.github.com/users/jart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jart/subscriptions","organizations_url":"https://api.github.com/users/jart/orgs","repos_url":"https://api.github.com/users/jart/repos","events_url":"https://api.github.com/users/jart/events{/privacy}","received_events_url":"https://api.github.com/users/jart/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-05-03T09:34:32Z","updated_at":"2018-05-04T01:08:01Z","closed_at":null,"author_association":"NONE","body":"### System information\r\n- **Have I written custom code (as opposed to using a stock example script provided in TensorFlow)**: yes\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Linux Ubuntu 16.04\r\n- **TensorFlow installed from (source or binary)**: binary\r\n- **TensorFlow version (use command below)**: v1.5.0-0-g37aa430d84 1.5.0\r\n- **Python version**: 3.6\r\n- **CUDA/cuDNN version**: release 9.0, V9.0.176\r\n- **GPU model and memory**: 1070 8G\r\n\r\n### Describe the Feature Request\r\nFor current version of Tensorflow, it will leak memory if we evaluate the sliced tensor as attached code and images, which isn't intuitive and hard to debug. It seems like the unused part of tensor will leak memory because there is no python object reference on it. I am not sure whether it could fixed or not, maybe it could show warning at least.\r\n\r\n### Source code / logs\r\n\r\n`import tensorflow as tf`\r\n`from pympler.tracker import SummaryTracker`\r\n`tracker = SummaryTracker()`\r\n`a = tf.zeros([3,4,5])`\r\n`sess = tf.Session()`\r\n\r\n`def leak_version():`\r\n`____return sess.run(a[0,0])`\r\n\r\n`def safe_version():`\r\n`____return sess.run(a)[0,0]` \r\n\r\n`for i in range(10):`\r\n`____tracker.print_diff()`\r\n`____# b = safe_version()`\r\n`____b = leak_version()`\r\n\r\n#### Trace of the Leak\r\n![image](https://user-images.githubusercontent.com/5878561/39568787-ed1af628-4ef5-11e8-80a0-b1e532b8c81c.png)\r\n\r\n#### Leak Version : visualize the object reference graph on object 'b' with depth=5 by Library objgraph\r\n![image](https://user-images.githubusercontent.com/5878561/39569067-adc03b18-4ef6-11e8-8d68-b5dee8a89eb0.png)\r\n\r\n#### Safe Version : visualize the object reference graph on object 'b' with depth=5 by Library objgraph\r\n![image](https://user-images.githubusercontent.com/5878561/39568928-57ccc000-4ef6-11e8-871d-7507a6dfefb4.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/386481495","html_url":"https://github.com/tensorflow/tensorflow/issues/19049#issuecomment-386481495","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19049","id":386481495,"user":{"login":"jart","id":49262,"avatar_url":"https://avatars1.githubusercontent.com/u/49262?v=4","gravatar_id":"","url":"https://api.github.com/users/jart","html_url":"https://github.com/jart","followers_url":"https://api.github.com/users/jart/followers","following_url":"https://api.github.com/users/jart/following{/other_user}","gists_url":"https://api.github.com/users/jart/gists{/gist_id}","starred_url":"https://api.github.com/users/jart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jart/subscriptions","organizations_url":"https://api.github.com/users/jart/orgs","repos_url":"https://api.github.com/users/jart/repos","events_url":"https://api.github.com/users/jart/events{/privacy}","received_events_url":"https://api.github.com/users/jart/received_events","type":"User","site_admin":false},"created_at":"2018-05-04T01:08:01Z","updated_at":"2018-05-04T01:08:01Z","author_association":"MEMBER","body":"@rmlarsen There may be a memory leak in `tf.strided_slice`."}}
{"actor":{"display_login":"jart"}}