Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include "common_test.h" |
| 4 | |
| 5 | namespace art { |
| 6 | |
| 7 | class HeapTest : public CommonTest {}; |
| 8 | |
jeffhao | c116070 | 2011-10-27 15:48:45 -0700 | [diff] [blame] | 9 | TEST_F(HeapTest, ClearGrowthLimit) { |
| 10 | int64_t max_memory_before = Heap::GetMaxMemory(); |
| 11 | int64_t total_memory_before = Heap::GetTotalMemory(); |
| 12 | Heap::ClearGrowthLimit(); |
| 13 | int64_t max_memory_after = Heap::GetMaxMemory(); |
| 14 | int64_t total_memory_after = Heap::GetTotalMemory(); |
| 15 | EXPECT_GE(max_memory_after, max_memory_before); |
| 16 | EXPECT_GE(total_memory_after, total_memory_before); |
| 17 | } |
| 18 | |
Brian Carlstrom | 693267a | 2011-09-06 09:25:34 -0700 | [diff] [blame] | 19 | TEST_F(HeapTest, GarbageCollectClassLinkerInit) { |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 20 | // garbage is created during ClassLinker::Init |
Elliott Hughes | 3b6baaa | 2011-10-14 19:13:56 -0700 | [diff] [blame] | 21 | |
| 22 | Class* c = class_linker_->FindSystemClass("[Ljava/lang/Object;"); |
| 23 | for (size_t i = 0; i < 1024; ++i) { |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 24 | SirtRef<ObjectArray<Object> > array(ObjectArray<Object>::Alloc(c, 2048)); |
Elliott Hughes | 3b6baaa | 2011-10-14 19:13:56 -0700 | [diff] [blame] | 25 | for (size_t j = 0; j < 2048; ++j) { |
| 26 | array->Set(j, String::AllocFromModifiedUtf8("hello, world!")); |
| 27 | } |
| 28 | } |
| 29 | |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 30 | Heap::CollectGarbage(); |
| 31 | } |
| 32 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 33 | } // namespace art |