Release resources associated with the Session. Blocks until there are no active executions (Session.Runner#run() calls). A Session is not usable after close returns.
()
| 88 | * is not usable after close returns. |
| 89 | */ |
| 90 | @Override |
| 91 | public void close() { |
| 92 | graphRef.close(); |
| 93 | synchronized (nativeHandleLock) { |
| 94 | if (nativeHandle == 0) { |
| 95 | return; |
| 96 | } |
| 97 | while (numActiveRuns > 0) { |
| 98 | try { |
| 99 | nativeHandleLock.wait(); |
| 100 | } catch (InterruptedException e) { |
| 101 | Thread.currentThread().interrupt(); |
| 102 | // Possible leak of the Session and Graph in this case? |
| 103 | return; |
| 104 | } |
| 105 | } |
| 106 | delete(nativeHandle); |
| 107 | nativeHandle = 0; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Run {@link Operation}s and evaluate {@link Tensor Tensors}. |