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

Unified Diff: test/JsEngine.cpp

Issue 29361562: Issue 3594 - remove circular references JsEngine-JsValue-JsEngine (Closed)
Patch Set: temporary workaround for race condition Created Dec. 1, 2016, 10:26 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
« src/JsValue.cpp ('K') | « test/FilterEngine.cpp ('k') | test/Prefs.cpp » ('j') | 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 3684620c57301f61423d903ec7dfc8e5fc680422..d2e1e37f88f9b26bfbc361b13a67f3867412fa8a 100644
--- a/test/JsEngine.cpp
+++ b/test/JsEngine.cpp
@@ -134,3 +134,23 @@ 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());
+}
+
+TEST(NewJsEngineTest, MemoryLeak_NoLeak)
+{
+ // v8::Isolate by default requires 32MB, 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.
+ int i = 1000;
+ while (i-->0)
+ {
+ AdblockPlus::JsEngine::New();
+ }
+}
« src/JsValue.cpp ('K') | « test/FilterEngine.cpp ('k') | test/Prefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld