-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemoryAllocatorTest.h
42 lines (37 loc) · 1.26 KB
/
MemoryAllocatorTest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#define _COMPILE_UNITTEST 0
#if _COMPILE_UNITTEST
#include "GCMemoryAllocator.h"
class MemoryAllocatorTest {
private:
GCMemoryAllocator memoryAllocator;
public:
void test() {
using namespace std;
const int size = 22000;
GCPhase::SwitchToNextPhase();
void* last = nullptr;
for (int i = 0; i < 100000; i++) {
void* object1 = memoryAllocator.allocate(size);
if (last != nullptr) {
std::shared_ptr<GCRegion> region = memoryAllocator.getRegion(last);
//region->mark(object1, size);
cout << MarkStateUtil::toString(region->bitmap->getMarkState(last)) << endl;
}
last = object1;
}
GCPhase::SwitchToNextPhase();
GCPhase::SwitchToNextPhase();
memoryAllocator.triggerRelocation();
for (int i = 0; i < 1000; i++) {
void* object1 = memoryAllocator.allocate(size);
if (last != nullptr) {
std::shared_ptr<GCRegion> region = memoryAllocator.getRegion(last);
//region->mark(object1, size);
cout << MarkStateUtil::toString(region->bitmap->getMarkState(last)) << endl;
}
last = object1;
}
}
};
#endif