MCPcopy Create free account
hub / github.com/ByConity/ByConity / allocImpl

Function allocImpl

src/Common/CurrentMemoryTracker.cpp:46–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 = ((g_total_untracked_memory_limit_encoded & 0x0f) << (g_total_untracked_memory_limit_encoded >> 4)) << 10;
45
46 void allocImpl(Int64 size, bool throw_if_memory_exceeded)
47 {
48 if (auto * memory_tracker = getMemoryTracker())
49 {
50 if (current_thread)
51 {
52 current_thread->untracked_memory += size;
53 if (current_thread->untracked_memory > current_thread->untracked_memory_limit)
54 {
55 /// Zero untracked before track. If tracker throws out-of-limit we would be able to alloc up to untracked_memory_limit bytes
56 /// more. It could be useful to enlarge Exception message in rethrow logic.
57 Int64 tmp = current_thread->untracked_memory;
58 current_thread->untracked_memory = 0;
59 memory_tracker->allocImpl(tmp, throw_if_memory_exceeded);
60 }
61 }
62 /// total_memory_tracker only, use total_untracked_memory_limit to avoid perfermance issue
63 else
64 {
65 total_untracked_memory += size;
66 if (total_untracked_memory > total_untracked_memory_limit)
67 {
68 Int64 tmp = total_untracked_memory;
69 total_untracked_memory = 0;
70 /// Update limit
71 total_untracked_memory_limit
72 = ((g_total_untracked_memory_limit_encoded & 0x0f) << (g_total_untracked_memory_limit_encoded >> 4)) << 10;
73 memory_tracker->allocImpl(tmp, throw_if_memory_exceeded);
74 }
75 }
76 }
77 }
78}
79
80void check()

Callers 4

allocFunction · 0.85
allocNoThrowFunction · 0.85
allocMethod · 0.85
allocNoThrowMethod · 0.85

Calls 2

getMemoryTrackerFunction · 0.85
allocImplMethod · 0.80

Tested by

no test coverage detected