static void testLeak(size_t alloc_size) { RuntimeOption::EvalGCTriggerPct = 0.50; RuntimeOption::EvalGCMinTrigger = 4 << 20; tl_heap->collect("testLeak"); tl_heap->setGCEnabled(true); clearSurpriseFlag(MemExceededFlag); tl_heap->setMemoryLimit(100 << 20); auto const target_alloc = int64_t{5} << 30; auto const vec_cap = (alloc_size - sizeof(ArrayData)) / sizeof(TypedValue); auto const vec = [vec_cap] { VecArrayInit vec{vec_cap}; for (int j = 0; j < vec_cap; ++j) { vec.append(make_tv<KindOfNull>()); } return vec.toArray(); }(); auto const start_alloc = tl_heap->getStatsRaw().mmAllocated(); for (int64_t i = 0; ; ++i) { auto vec_copy = vec; vec_copy.set(0, make_tv<KindOfInt64>(i)); vec_copy.detach(); if (tl_heap->getStatsRaw().mmAllocated() - start_alloc > target_alloc) { break; } if (UNLIKELY(checkSurpriseFlags())) handle_request_surprise(); } }
void check_request_surprise_unlikely() { if (UNLIKELY(checkSurpriseFlags())) check_request_surprise(); }