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() {
107
107
108
108
@ Test
109
109
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...
113
111
for (int i = 0 ; i < 1000 ; i ++) {
114
112
TString .scalarOf (A_LARGE_STRING ).close ();
113
+ System .gc ();
115
114
}
116
115
117
- System .gc ();
118
- Thread .sleep (100 );
119
116
long bytesBefore = Pointer .physicalBytes ();
120
117
121
118
for (int i = 0 ; i < 1000 ; i ++) {
122
119
TString .scalarOf (A_LARGE_STRING ).close ();
120
+ System .gc ();
123
121
}
124
122
125
- System .gc ();
126
- Thread .sleep (100 );
127
123
long bytesAfter = Pointer .physicalBytes ();
128
124
125
+ // the difference should ideally be 0, but the JVM and TF Core may be holding onto some unrelated stuff...
129
126
assertTrue (Math .abs (bytesAfter - bytesBefore ) < 10_000_000 );
130
127
}
131
128
You can’t perform that action at this time.
0 commit comments