Add (disabled) test for cppgc heap bloating.
For discussion of GC-triggering conditions. Currently gets
# Fatal error in ../../v8/src/heap/cppgc/page-memory.cc, line 69
# Oilpan: Out of memory (Oilpan: Reserving memory.)
unless we explicitly invoke GC.
Change-Id: I8078d1579f7b5fd6b7b0ffd28ec33d3f1f47bbe3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/94170
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/gc/heap_unittest.cpp b/fxjs/gc/heap_unittest.cpp
index 9e89eba..16d331a 100644
--- a/fxjs/gc/heap_unittest.cpp
+++ b/fxjs/gc/heap_unittest.cpp
@@ -9,6 +9,7 @@
#include "testing/fxgc_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/v8_test_environment.h"
#include "third_party/base/containers/contains.h"
#include "v8/include/cppgc/allocation.h"
#include "v8/include/cppgc/persistent.h"
@@ -53,6 +54,12 @@
cppgc::Persistent<PseudoCollectible> holdee_;
};
+class Bloater : public cppgc::GarbageCollected<Bloater> {
+ public:
+ void Trace(cppgc::Visitor* visitor) const {}
+ uint8_t bloat_[65536];
+};
+
} // namespace
class HeapUnitTest : public FXGCUnitTest {
@@ -158,3 +165,13 @@
EXPECT_EQ(0u, PseudoCollectible::LiveCount());
EXPECT_EQ(1u, PseudoCollectible::DeadCount());
}
+
+// TODO(tsepez): find conditions that will trigger a GC.
+TEST_F(HeapUnitTest, DISABLED_Bloat) {
+ FXGCScopedHeap heap1 = FXGC_CreateHeap();
+ ASSERT_TRUE(heap1);
+ for (int i = 0; i < 100000; ++i) {
+ cppgc::MakeGarbageCollected<Bloater>(heap1->GetAllocationHandle());
+ V8TestEnvironment::PumpPlatformMessageLoop(isolate());
+ }
+}