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

Side by Side Diff: Source/wtf/PartitionAllocTest.cpp

Issue 1155293007: Expose ReleaseFreeMemory to free up memory on memory pressure or idle cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing test calls. Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « Source/wtf/PartitionAlloc.cpp ('k') | Source/wtf/Partitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 MockPartitionStatsDumper mockStatsDumperGeneric; 1487 MockPartitionStatsDumper mockStatsDumperGeneric;
1488 partitionDumpStatsGeneric(genericAllocator.root(), "mock_generic_allocat or", &mockStatsDumperGeneric); 1488 partitionDumpStatsGeneric(genericAllocator.root(), "mock_generic_allocat or", &mockStatsDumperGeneric);
1489 EXPECT_FALSE(mockStatsDumperGeneric.IsMemoryAllocationRecorded()); 1489 EXPECT_FALSE(mockStatsDumperGeneric.IsMemoryAllocationRecorded());
1490 1490
1491 const WTF::PartitionBucketMemoryStats* stats = mockStatsDumperGeneric.Ge tBucketStats(2048); 1491 const WTF::PartitionBucketMemoryStats* stats = mockStatsDumperGeneric.Ge tBucketStats(2048);
1492 EXPECT_TRUE(stats); 1492 EXPECT_TRUE(stats);
1493 EXPECT_TRUE(stats->isValid); 1493 EXPECT_TRUE(stats->isValid);
1494 EXPECT_EQ(WTF::kSystemPageSize, stats->freeableBytes); 1494 EXPECT_EQ(WTF::kSystemPageSize, stats->freeableBytes);
1495 EXPECT_EQ(WTF::kSystemPageSize, stats->residentBytes); 1495 EXPECT_EQ(WTF::kSystemPageSize, stats->residentBytes);
1496 } 1496 }
1497 partitionPurgeMemory(genericAllocator.root()); 1497 partitionPurgeMemoryGeneric(genericAllocator.root());
1498 { 1498 {
1499 MockPartitionStatsDumper mockStatsDumperGeneric; 1499 MockPartitionStatsDumper mockStatsDumperGeneric;
1500 partitionDumpStatsGeneric(genericAllocator.root(), "mock_generic_allocat or", &mockStatsDumperGeneric); 1500 partitionDumpStatsGeneric(genericAllocator.root(), "mock_generic_allocat or", &mockStatsDumperGeneric);
1501 EXPECT_FALSE(mockStatsDumperGeneric.IsMemoryAllocationRecorded()); 1501 EXPECT_FALSE(mockStatsDumperGeneric.IsMemoryAllocationRecorded());
1502 1502
1503 const WTF::PartitionBucketMemoryStats* stats = mockStatsDumperGeneric.Ge tBucketStats(2048); 1503 const WTF::PartitionBucketMemoryStats* stats = mockStatsDumperGeneric.Ge tBucketStats(2048);
1504 EXPECT_TRUE(stats); 1504 EXPECT_TRUE(stats);
1505 EXPECT_TRUE(stats->isValid); 1505 EXPECT_TRUE(stats->isValid);
1506 EXPECT_EQ(0u, stats->freeableBytes); 1506 EXPECT_EQ(0u, stats->freeableBytes);
1507 EXPECT_EQ(0u, stats->residentBytes); 1507 EXPECT_EQ(0u, stats->residentBytes);
1508 } 1508 }
1509 // Calling purge again here is a good way of testing we didn't mess up the 1509 // Calling purge again here is a good way of testing we didn't mess up the
1510 // state of the free cache ring. 1510 // state of the free cache ring.
1511 partitionPurgeMemory(genericAllocator.root()); 1511 partitionPurgeMemoryGeneric(genericAllocator.root());
1512 TestShutdown(); 1512 TestShutdown();
1513 } 1513 }
1514 1514
1515 // Tests that the countLeadingZeros() functions work to our satisfaction. 1515 // Tests that the countLeadingZeros() functions work to our satisfaction.
1516 // It doesn't seem worth the overhead of a whole new file for these tests, so 1516 // It doesn't seem worth the overhead of a whole new file for these tests, so
1517 // we'll put them here since partitionAllocGeneric will depend heavily on these 1517 // we'll put them here since partitionAllocGeneric will depend heavily on these
1518 // functions working correctly. 1518 // functions working correctly.
1519 TEST(PartitionAllocTest, CLZWorks) 1519 TEST(PartitionAllocTest, CLZWorks)
1520 { 1520 {
1521 EXPECT_EQ(32u, WTF::countLeadingZeros32(0u)); 1521 EXPECT_EQ(32u, WTF::countLeadingZeros32(0u));
(...skipping 11 matching lines...) Expand all
1533 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0u)); 1533 EXPECT_EQ(32u, WTF::countLeadingZerosSizet(0u));
1534 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1u)); 1534 EXPECT_EQ(31u, WTF::countLeadingZerosSizet(1u));
1535 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1u << 30)); 1535 EXPECT_EQ(1u, WTF::countLeadingZerosSizet(1u << 30));
1536 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1u << 31)); 1536 EXPECT_EQ(0u, WTF::countLeadingZerosSizet(1u << 31));
1537 #endif 1537 #endif
1538 } 1538 }
1539 1539
1540 } // namespace 1540 } // namespace
1541 1541
1542 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 1542 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
OLDNEW
« no previous file with comments | « Source/wtf/PartitionAlloc.cpp ('k') | Source/wtf/Partitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698