forked from ruihong123/dLSM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory_leak.cpp
42 lines (40 loc) · 1.24 KB
/
memory_leak.cpp
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
//
// Created by ruihong on 9/30/21.
//
#include <stdlib.h>
#include <string>
#include <iostream>
#include "include/TimberSaw/db.h"
#include "include/TimberSaw/filter_policy.h"
#include "TimberSaw/comparator.h"
int main()
{
TimberSaw::DB* db;
TimberSaw::Options options;
options.now_compute_compactions = 1;
options.max_background_flushes = 1;
options.comparator = TimberSaw::BytewiseComparator();
//TODO: implement the FIlter policy before initial the database
auto b_policy = TimberSaw::NewBloomFilterPolicy(options.bloom_bits);
options.filter_policy = b_policy;
TimberSaw::Status s = TimberSaw::DB::Open(options, "mem_leak", &db);
delete db;
// DestroyDB("mem_leak", TimberSaw::Options());
TimberSaw::DB::Open(options, "mem_leak", &db);
std::string value;
std::string key;
auto option_wr = TimberSaw::WriteOptions();
for (int i = 0; i<1000000; i++){
key = std::to_string(i);
key.insert(0, 20 - key.length(), '1');
value = std::to_string(std::rand() % ( 10000000 ));
value.insert(0, 400 - value.length(), '1');
s = db->Put(option_wr, key, value);
if (!s.ok()){
std::cerr << s.ToString() << std::endl;
}
// std::cout << "iteration number " << i << std::endl;
}
delete db;
delete b_policy;
}