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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/unit_test.h" 6 #include "vm/unit_test.h"
7 #include "vm/virtual_memory.h" 7 #include "vm/virtual_memory.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 21 matching lines...) Expand all
32 buf[1] = 'c'; 32 buf[1] = 'c';
33 buf[2] = '/'; 33 buf[2] = '/';
34 buf[3] = 'd'; 34 buf[3] = 'd';
35 buf[4] = 'c'; 35 buf[4] = 'c';
36 buf[5] = 0; 36 buf[5] = 0;
37 EXPECT_STREQ("ac/dc", buf); 37 EXPECT_STREQ("ac/dc", buf);
38 38
39 delete vm; 39 delete vm;
40 } 40 }
41 41
42
43 UNIT_TEST_CASE(FreeVirtualMemory) {
44 // Reservations should always be handed back to OS upon destruction.
45 const intptr_t kVirtualMemoryBlockSize = 10 * MB;
46 const intptr_t kIterations = 900; // Enough to exhaust 32-bit address space.
47 for (intptr_t i = 0; i < kIterations; ++i) {
48 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
49 vm->Commit(false);
Ivan Posva 2014/10/09 18:31:56 You might want to alternate the value for the exec
50 delete vm;
51 }
52 // Check that truncation does not introduce leaks.
53 for (intptr_t i = 0; i < kIterations; ++i) {
54 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
55 vm->Commit(false);
56 vm->Truncate(kVirtualMemoryBlockSize / 2, true);
57 delete vm;
58 }
59 for (intptr_t i = 0; i < kIterations; ++i) {
60 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
61 vm->Commit(false);
62 vm->Truncate(kVirtualMemoryBlockSize / 2, false);
63 delete vm;
64 }
65 for (intptr_t i = 0; i < kIterations; ++i) {
66 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
67 vm->Commit(false);
68 vm->Truncate(0, true);
69 delete vm;
70 }
71 for (intptr_t i = 0; i < kIterations; ++i) {
72 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize);
73 vm->Commit(false);
74 vm->Truncate(0, false);
75 delete vm;
76 }
77 }
78
42 } // namespace dart 79 } // namespace dart
OLDNEW
« 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