File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/types Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -107,25 +107,22 @@ public void initializingTensorWithRawBytes() {
107107
108108 @ Test
109109 public void testNoLeaks () throws Exception {
110- System .gc ();
111- Thread .sleep (100 );
112-
110+ // warm up and try to get all JIT compilation done to stabilize memory usage...
113111 for (int i = 0 ; i < 1000 ; i ++) {
114112 TString .scalarOf (A_LARGE_STRING ).close ();
113+ System .gc ();
115114 }
116115
117- System .gc ();
118- Thread .sleep (100 );
119116 long bytesBefore = Pointer .physicalBytes ();
120117
121118 for (int i = 0 ; i < 1000 ; i ++) {
122119 TString .scalarOf (A_LARGE_STRING ).close ();
120+ System .gc ();
123121 }
124122
125- System .gc ();
126- Thread .sleep (100 );
127123 long bytesAfter = Pointer .physicalBytes ();
128124
125+ // the difference should ideally be 0, but the JVM and TF Core may be holding onto some unrelated stuff...
129126 assertTrue (Math .abs (bytesAfter - bytesBefore ) < 10_000_000 );
130127 }
131128
You can’t perform that action at this time.
0 commit comments