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

Unified Diff: runtime/vm/virtual_memory_test.cc

Issue 648473002: Add unit test for freeing VirtualMemory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/virtual_memory_test.cc
===================================================================
--- runtime/vm/virtual_memory_test.cc (revision 41017)
+++ runtime/vm/virtual_memory_test.cc (working copy)
@@ -39,4 +39,41 @@
delete vm;
}
+
+UNIT_TEST_CASE(FreeVirtualMemory) {
+ // Reservations should always be handed back to OS upon destruction.
+ const intptr_t kVirtualMemoryBlockSize = 10 * MB;
+ const intptr_t kIterations = 900; // Enough to exhaust 32-bit address space.
+ for (intptr_t i = 0; i < kIterations; ++i) {
+ VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
+ vm->Commit(false);
+ delete vm;
+ }
+ // Check that truncation does not introduce leaks.
+ for (intptr_t i = 0; i < kIterations; ++i) {
+ VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
+ vm->Commit(false);
+ vm->Truncate(kVirtualMemoryBlockSize / 2, true);
+ delete vm;
+ }
+ for (intptr_t i = 0; i < kIterations; ++i) {
+ VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
+ vm->Commit(true);
+ vm->Truncate(kVirtualMemoryBlockSize / 2, false);
+ delete vm;
+ }
+ for (intptr_t i = 0; i < kIterations; ++i) {
+ VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
+ vm->Commit(true);
+ vm->Truncate(0, true);
+ delete vm;
+ }
+ for (intptr_t i = 0; i < kIterations; ++i) {
+ VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
+ vm->Commit(false);
+ vm->Truncate(0, false);
+ delete vm;
+ }
+}
+
} // namespace dart
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698