@@ -48,6 +48,7 @@ public void checkLimitedMemoryScenarios() { //Requesting application
48
48
//########## Owning Implementation
49
49
// This part would actually be part of the Memory owning implementation so it is faked here
50
50
WritableMemory wmem = WritableMemory .allocateDirect (initBytes , ByteOrder .nativeOrder (), new DefaultMemoryRequestServer ());
51
+ WritableMemory wmemCopy = wmem ;
51
52
println ("Initial mem size: " + wmem .getCapacity ());
52
53
53
54
//########## Receiving Application
@@ -70,6 +71,8 @@ public void checkLimitedMemoryScenarios() { //Requesting application
70
71
// so the the wmem reference is invalid. Use the sketch to get the last memory reference.
71
72
WritableMemory lastMem = usk1 .getMemory ();
72
73
println ("Final mem size: " + usk1 .getMemory ().getCapacity ());
74
+ assertTrue (wmemCopy .isDirect ());
75
+ assertFalse (wmemCopy .isAlive ());
73
76
}
74
77
75
78
@ Test
@@ -79,6 +82,7 @@ public void checkGrowBaseBuf() {
79
82
final int initBytes = (4 + (u / 2 )) << 3 ; // not enough to hold everything
80
83
81
84
WritableMemory wmem = WritableMemory .allocateDirect (initBytes , ByteOrder .nativeOrder (), new DefaultMemoryRequestServer ());
85
+ WritableMemory wmemCopy = wmem ;
82
86
println ("Initial mem size: " + wmem .getCapacity ());
83
87
final UpdateDoublesSketch usk1 = DoublesSketch .builder ().setK (k ).build (wmem );
84
88
for (int i = 1 ; i <= u ; i ++) {
@@ -88,6 +92,8 @@ public void checkGrowBaseBuf() {
88
92
println ("curCombBufItemCap: " + currentSpace );
89
93
assertEquals (currentSpace , 2 * k );
90
94
println ("last Mem Cap: " + usk1 .getMemory ().getCapacity ());
95
+ assertTrue (wmemCopy .isDirect ());
96
+ assertFalse (wmemCopy .isAlive ());
91
97
}
92
98
93
99
@ Test
@@ -97,6 +103,7 @@ public void checkGrowCombBuf() {
97
103
final int initBytes = ((2 * k ) + 4 ) << 3 ; //just room for BB
98
104
99
105
WritableMemory wmem = WritableMemory .allocateDirect (initBytes , ByteOrder .nativeOrder (), new DefaultMemoryRequestServer ());
106
+ WritableMemory wmemCopy = wmem ;
100
107
println ("Initial mem size: " + wmem .getCapacity ());
101
108
final UpdateDoublesSketch usk1 = DoublesSketch .builder ().setK (k ).build (wmem );
102
109
for (int i = 1 ; i <= u ; i ++) {
@@ -108,6 +115,8 @@ public void checkGrowCombBuf() {
108
115
final int newSpace = usk1 .getCombinedBufferItemCapacity ();
109
116
println ("newCombBurItemCap: " + newSpace );
110
117
assertEquals (newCB .length , 3 * k );
118
+ assertTrue (wmemCopy .isDirect ());
119
+ assertFalse (wmemCopy .isAlive ());
111
120
}
112
121
113
122
@ Test
@@ -119,6 +128,7 @@ public void checkGrowFromWrappedEmptySketch() {
119
128
final Memory origSketchMem = Memory .wrap (usk1 .toByteArray ());
120
129
121
130
WritableMemory wmem = WritableMemory .allocateDirect (initBytes , ByteOrder .nativeOrder (), new DefaultMemoryRequestServer ());
131
+ WritableMemory wmemCopy = wmem ;
122
132
origSketchMem .copyTo (0 , wmem , 0 , initBytes );
123
133
UpdateDoublesSketch usk2 = DirectUpdateDoublesSketch .wrapInstance (wmem );
124
134
assertTrue (wmem .isSameResource (usk2 .getMemory ()));
@@ -135,6 +145,8 @@ public void checkGrowFromWrappedEmptySketch() {
135
145
136
146
final int expectedSize = COMBINED_BUFFER + ((2 * k ) << 3 );
137
147
assertEquals (mem2 .getCapacity (), expectedSize );
148
+ assertTrue (wmemCopy .isDirect ());
149
+ assertFalse (wmemCopy .isAlive ());
138
150
}
139
151
140
152
@ Test
0 commit comments