Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Unified Diff: test/cctest/test-strings.cc

Issue 53089: Fixed test memory leaks (Closed)
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-strings.cc
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index f8c1a469251c54087a673883267809a7945448f4..b38d6457af37941cc3b9ee4e831b5ae232db896c 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -11,6 +11,7 @@
#include "factory.h"
#include "cctest.h"
+#include "zone-inl.h"
unsigned int seed = 123;
@@ -48,6 +49,8 @@ static const int SUPER_DEEP_DEPTH = 80 * 1024;
static void InitializeBuildingBlocks(
Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS]) {
+ // A list of pointers that we don't have any interest in cleaning up.
+ // If they are reachable from a root then leak detection won't complain.
for (int i = 0; i < NUMBER_OF_BUILDING_BLOCKS; i++) {
int len = gen() % 16;
if (len > 14) {
@@ -80,7 +83,7 @@ static void InitializeBuildingBlocks(
}
case 2: {
class Resource: public v8::String::ExternalStringResource,
- public Malloced {
+ public ZoneObject {
public:
explicit Resource(Vector<const uc16> string): data_(string.start()) {
length_ = string.length();
@@ -92,7 +95,7 @@ static void InitializeBuildingBlocks(
const uc16* data_;
size_t length_;
};
- uc16* buf = NewArray<uc16>(len);
+ uc16* buf = Zone::NewArray<uc16>(len);
for (int j = 0; j < len; j++) {
buf[j] = gen() % 65536;
}
@@ -212,6 +215,7 @@ TEST(Traverse) {
InitializeVM();
v8::HandleScope scope;
Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS];
+ ZoneScope zone(DELETE_ON_EXIT);
InitializeBuildingBlocks(building_blocks);
Handle<String> flat = ConstructBalanced(building_blocks);
FlattenString(flat);
@@ -303,6 +307,7 @@ TEST(Slice) {
InitializeVM();
v8::HandleScope scope;
Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS];
+ ZoneScope zone(DELETE_ON_EXIT);
InitializeBuildingBlocks(building_blocks);
seed = 42;

Powered by Google App Engine
This is Rietveld 408576698