15
15
#include " include/proxy-wasm/wasm.h"
16
16
17
17
#include " gtest/gtest.h"
18
+ #include < unordered_set>
18
19
19
20
#include " test/utility.h"
20
21
@@ -177,6 +178,8 @@ TEST_P(TestVm, AlwaysApplyCanary) {
177
178
// For each create Wasm, canary should be done.
178
179
EXPECT_EQ (canary_count, 1 );
179
180
181
+ std::unordered_set<std::shared_ptr<WasmHandleBase>> reference_holder;
182
+
180
183
for (const auto &root_id : root_ids) {
181
184
for (const auto &vm_id : vm_ids) {
182
185
for (const auto &vm_config : vm_configs) {
@@ -208,6 +211,10 @@ TEST_P(TestVm, AlwaysApplyCanary) {
208
211
}
209
212
210
213
ASSERT_TRUE (wasm_handle_comp && wasm_handle_comp->wasm ());
214
+ // Keep the reference of wasm_handle_comp in order to utilize the WasmHandleBase
215
+ // cache of createWasm. If we don't keep the reference, WasmHandleBase and VM will be
216
+ // destroyed for each iteration.
217
+ reference_holder.insert (wasm_handle_comp);
211
218
212
219
EXPECT_TRUE (TestContext::isGlobalLogged (" onConfigure: " + root_id));
213
220
@@ -228,10 +235,6 @@ TEST_P(TestVm, AlwaysApplyCanary) {
228
235
}
229
236
// For each create Wasm, canary should be done.
230
237
EXPECT_EQ (canary_count, 1 );
231
-
232
- if (wasm_handle_comp->wasm () != wasm_handle_baseline->wasm ()) {
233
- wasm_handle_comp->kill ();
234
- }
235
238
}
236
239
}
237
240
}
0 commit comments