1#include <iostream>
2#include <Common/Allocator.h>
3
4int main()
5{
6 Allocator<true> alloc;
7
8 if (1)
9 {
10 size_t size = 50000000;
11 auto p = alloc.alloc(size);
12 size_t old_size = size;
13 for (; size < 1000000000; size += 50000000)
14 {
15 p = alloc.realloc(p, old_size, size);
16 old_size = size;
17 }
18 alloc.free(p, old_size);
19 std::cerr << "50mb+50mb+.. ok.\n";
20 }
21
22
23 {
24 size_t size = 1000000000;
25 auto p = alloc.alloc(size);
26 size_t old_size = size;
27 //try
28 //{
29 // Now possible jump 65mb->63mb
30 for (; size > 1000; size /= 2)
31 {
32 p = alloc.realloc(p, old_size, size);
33 old_size = size;
34 }
35 /* }
36 catch (...)
37 {
38 size = old_size;
39 std::cerr << "ok. impossible catch.\n";
40 } */
41 alloc.free(p, old_size);
42 std::cerr << "1gb,512mb,128mb,.. ok.\n";
43 }
44
45
46 if (1)
47 {
48 size_t size = 1;
49 auto p = alloc.alloc(size);
50 size_t old_size = size;
51 for (; size < 1000000000; size *= 2)
52 {
53 p = alloc.realloc(p, old_size, size);
54 old_size = size;
55 }
56 alloc.free(p, old_size);
57 std::cerr << "1,2,4,8,..,1G ok.\n";
58 }
59
60 std::cerr << "ok.\n";
61}
62