blob: 77b98e4c33175c7fcf74ac3455e812746e2fe091 [file] [log] [blame]
Brian Carlstrom1f870082011-08-23 16:02:11 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#include "common_test.h"
4
5namespace art {
6
7class HeapTest : public CommonTest {};
8
jeffhaoc1160702011-10-27 15:48:45 -07009TEST_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 Carlstrom693267a2011-09-06 09:25:34 -070019TEST_F(HeapTest, GarbageCollectClassLinkerInit) {
Brian Carlstrom1f870082011-08-23 16:02:11 -070020 // garbage is created during ClassLinker::Init
Elliott Hughes3b6baaa2011-10-14 19:13:56 -070021
22 Class* c = class_linker_->FindSystemClass("[Ljava/lang/Object;");
23 for (size_t i = 0; i < 1024; ++i) {
Brian Carlstrom40381fb2011-10-19 14:13:40 -070024 SirtRef<ObjectArray<Object> > array(ObjectArray<Object>::Alloc(c, 2048));
Elliott Hughes3b6baaa2011-10-14 19:13:56 -070025 for (size_t j = 0; j < 2048; ++j) {
26 array->Set(j, String::AllocFromModifiedUtf8("hello, world!"));
27 }
28 }
29
Brian Carlstrom1f870082011-08-23 16:02:11 -070030 Heap::CollectGarbage();
31}
32
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070033} // namespace art