MCPcopy Create free account
hub / github.com/RenderKit/oidn / trim

Method trim

core/arena.cpp:18–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 {}
17
18 void ScratchArenaManager::trim()
19 {
20 for (auto& item : allocs)
21 {
22 Alloc& alloc = item.second;
23
24 if (alloc.arenas.empty())
25 {
26 // Free the heap because no more arenas are attached
27 alloc.heap.reset();
28 }
29 else
30 {
31 // Decrease the size of the heap if possible
32 size_t newHeapByteSize = 0;
33 for (auto arena : alloc.arenas)
34 newHeapByteSize = max(newHeapByteSize, arena->byteSize);
35
36 if (newHeapByteSize < alloc.heap->getByteSize())
37 alloc.heap->realloc(newHeapByteSize);
38 }
39 }
40 }
41
42 // Attaches a scratch arena and returns the heap that backs its memory
43 Heap* ScratchArenaManager::attach(ScratchArena* arena)

Callers 1

trimScratchMethod · 0.80

Calls 5

reallocMethod · 0.80
maxFunction · 0.70
emptyMethod · 0.45
resetMethod · 0.45
getByteSizeMethod · 0.45

Tested by

no test coverage detected