blob: 4afca499a242c8916f699fe636453ec9517439b8 (
plain) (
blame)
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
43
44
45
46
47
48
49
50
51
52
|
#include "../pg_compat.h"
extern "C" {
#include <yql/essentials/parser/pg_wrapper/postgresql/src/include/postgres.h>
#include <yql/essentials/parser/pg_wrapper/postgresql/src/include/utils/memutils.h>
}
#include "arena_ctx.h"
#include <yql/essentials/minikql/mkql_alloc.h>
#include <library/cpp/testing/unittest/registar.h>
namespace NYql {
Y_UNIT_TEST_SUITE(TPGMemoryTests) {
Y_UNIT_TEST(TestArenaContextBasic) {
TArenaMemoryContext arena;
auto p1 = palloc(123);
auto p2 = palloc(456);
Y_UNUSED(p2);
pfree(p1);
}
Y_UNIT_TEST(TestMkqlContextBasic) {
NKikimr::NMiniKQL::TScopedAlloc alloc(__LOCATION__);
auto p1 = palloc(123);
auto p2 = palloc(456);
Y_UNUSED(p2);
pfree(p1);
}
Y_UNIT_TEST(TestArenaContextCleanupChild) {
TArenaMemoryContext arena;
auto tmpContext = AllocSetContextCreate(CurrentMemoryContext, "Tmp", ALLOCSET_SMALL_SIZES);
auto oldcontext = MemoryContextSwitchTo(tmpContext);
auto p1 = palloc(123);
Y_UNUSED(p1);
MemoryContextSwitchTo(oldcontext);
}
Y_UNIT_TEST(TestMkqlContextCleanupChild) {
NKikimr::NMiniKQL::TScopedAlloc alloc(__LOCATION__);
auto tmpContext = AllocSetContextCreate(CurrentMemoryContext, "Tmp", ALLOCSET_SMALL_SIZES);
auto oldcontext = MemoryContextSwitchTo(tmpContext);
auto p1 = palloc(123);
Y_UNUSED(p1);
MemoryContextSwitchTo(oldcontext);
}
}
}
|