Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/JsEngine.cpp

Issue 29442722: Issue 3593 - stop sharing v8::Isolate among tests (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: address comments Created May 26, 2017, 10:54 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/BaseJsTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/JsEngine.cpp
diff --git a/test/JsEngine.cpp b/test/JsEngine.cpp
index b26c794ffabb4a2a6ec2c19fe0adfceffed30c21..51bd37074b48fd91dcf27365f07baf1958c1e56a 100644
--- a/test/JsEngine.cpp
+++ b/test/JsEngine.cpp
@@ -188,3 +188,29 @@ TEST(NewJsEngineTest, GlobalPropertyTest)
ASSERT_EQ(foo.AsString(), "bar");
}
+TEST(NewJsEngineTest, MemoryLeak_NoCircularReferences)
+{
+ std::weak_ptr<AdblockPlus::JsEngine> weakJsEngine;
+ {
+ weakJsEngine = AdblockPlus::JsEngine::New();
+ }
+ EXPECT_FALSE(weakJsEngine.lock());
+}
+
+#if UINTPTR_MAX == UINT32_MAX // detection of 32-bit platform
+static_assert(sizeof(intptr_t) == 4, "It should be 32bit platform");
+TEST(NewJsEngineTest, 32bitsOnly_MemoryLeak_NoLeak)
+#else
+TEST(NewJsEngineTest, DISABLED_32bitsOnly_MemoryLeak_NoLeak)
+#endif
+{
+ // v8::Isolate by default requires 32MB (depends on platform), so if there is
+ // a memory leak than we will run out of memory on 32 bit platform because it
+ // will allocate 32000 MB which is less than 2GB where it reaches out of
+ // memory. Even on android where it allocates initially 16MB, the test still
+ // makes sense.
+ for (int i = 0; i < 1000; ++i)
+ {
+ AdblockPlus::JsEngine::New();
+ }
+}
« no previous file with comments | « test/BaseJsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld