Code size analysis#

pw_allocator: Flexible, safe, and measurable memory allocation

This module provides the Allocator interface, as well as several implementations of it. The tables below shows the relative code size for the interface and each of these implementations. The measurement includes a call to each method.

Allocator interface#

The following shows the code size incurred by the Allocator interface itself. A call to each method of the interface is measured using an empty implementation, NullAllocator.

Label

Segment

Delta

NullAllocator

FLASH

+4

quorem

+14

pw::internal_result::StatusOrData<>::StatusOrData<>()

+176

main

+4

p05.0

NEW

+314

pw::allocator::Allocator::DoReallocate()

NEW

+64

pw::allocator::NullAllocator

NEW

+40

pw::allocator::Allocator::New<>()

NEW

+38

pw::allocator::Allocator::Allocate()

NEW

+32

pw::allocator::Allocator::GetAllocatedLayout()

NEW

+22

pw::allocator::Allocator::DoGetAllocatedLayout()

NEW

+20

pw::allocator::NullAllocator::DoDeallocate()

NEW

+18

pw::allocator::Allocator::DoResize()

NEW

+16

__wrap_free

NEW

+16

pw::allocator::NullAllocator::~NullAllocator()

NEW

+14

pw::allocator::NullAllocator::DoAllocate()

NEW

+12

pw::allocator::internal::BaseUniquePtr::HasCapability()

NEW

+10

pw::allocator::Deallocator::Deallocate()

NEW

+10

pw::allocator::internal::BaseUniquePtr::Deallocate()

NEW

+8

operator delete()

NEW

+6

pw::allocator::Deallocator::DoGetCapacity()

NEW

+6

pw::allocator::Deallocator::DoQuery()

NEW

+4

pw::allocator::NullAllocator::kCapabilities

+848

Concrete allocator implementations#

The following are code sizes for each of the provided allocator implementations that directly manage the memory they use to fulfill requests. These are measured relative to the empty implementation measured above.

Label

Segment

Delta

BestFitBlockAllocator

FLASH

+136

main

+104

pw::allocator::Block<>::SplitImpl()

+88

pw::allocator::Block<>::CrashIfInvalid()

+86

pw::allocator::Block<>::MergeNext()

-2

pw::allocator::Allocator::New<>()

-2

pw_boot_PreStaticMemoryInit

+16

pw::allocator::Block<>::Next()

+14

pw::allocator::Block<>::Prev()

+2

pw::allocator::internal::BaseUniquePtr::Deallocate()

NEW

+166

pw::allocator::BestFitBlockAllocator<>::ChooseBlock()

NEW

+130

pw::allocator::Block<>::Resize()

NEW

+120

pw::allocator::Block<>::AdjustForAllocLast()

NEW

+90

pw::allocator::BlockAllocator<>::DoDeallocate()

NEW

+88

pw::allocator::BlockAllocator<>::FromUsableSpace<>()

NEW

+68

pw::allocator::BestFitBlockAllocator<>

NEW

+68

pw::allocator::BlockAllocator<>

NEW

+68

pw::allocator::BlockAllocator<>::DoGetUsableLayout()

NEW

+66

pw::allocator::BlockAllocator<>::DoGetAllocatedLayout()

NEW

+64

pw::allocator::BestFitBlockAllocator<>::~BestFitBlockAllocator()

NEW

+60

pw::allocator::BlockAllocator<>::DoResize()

NEW

+40

pw::allocator::BlockAllocator<>::DoAllocate()

NEW

+28

pw::allocator::BlockAllocator<>::UpdateLast()

NEW

+22

pw::allocator::BlockAllocator<>::DoQuery()

NEW

+20

pw::allocator::internal::GenericBlockAllocator::CrashOnAllocated()

NEW

+4

pw::allocator::Block<>::kAlignment

NEW

+4

pw::allocator::BlockAllocator<>::DoGetCapacity()

NEW

+4

pw::allocator::internal::GenericBlockAllocator::kCapabilities

+1,552

BuddyAllocator

FLASH

+40

[section .code]

-4

quorem

+80

main

+4

pw::allocator::NullAllocator::kCapabilities

NEW

+244

pw::allocator::internal::GenericBuddyAllocator::Deallocate()

NEW

+160

pw::allocator::internal::GenericBuddyAllocator::GenericBuddyAllocator()

NEW

+146

pw::allocator::internal::GenericBuddyAllocator::Allocate()

NEW

+112

pw::allocator::internal::GenericBuddyAllocator::CrashIfAllocated()

NEW

+68

pw::allocator::internal::Bucket::Init()

NEW

+64

pw::allocator::BuddyAllocator<>

NEW

+60

fit::internal::target<>::ops

NEW

+50

pw::allocator::internal::GenericBuddyAllocator::Query()

NEW

+44

pw::allocator::BuddyAllocator<>::~BuddyAllocator()

NEW

+42

pw::allocator::internal::Bucket::RemoveIf()

NEW

+40

pw::allocator::BuddyAllocator<>::DoAllocate()

NEW

+40

pw::allocator::internal::Bucket::Bucket()

NEW

+40

pw::allocator::internal::Bucket::count()

NEW

+32

pw::allocator::internal::Bucket::Remove()

NEW

+24

fit::internal::target<>::invoke()

NEW

+24

pw::allocator::internal::Bucket::Visit()

NEW

+18

pw::allocator::Deallocator::DoDeallocate()

NEW

+12

fit::internal::inline_trivial_target_move<>()

NEW

+8

pw::allocator::BuddyAllocator<>::DoQuery()

NEW

+8

pw::allocator::internal::Bucket::Add()

NEW

+6

fit::internal::generic_function_base<>::destroy_target()

NEW

+6

pw::allocator::BuddyAllocator<>::DoDeallocate()

NEW

+4

fit::internal::unshared_target_type_id()

NEW

+2

fit::internal::inline_target_get()

NEW

+2

fit::internal::trivial_target_destroy()

+1,376

BumpAllocator

FLASH

+24

main

-4

p05.0

NEW

+64

pw::allocator::BumpAllocator

NEW

+58

pw::allocator::BumpAllocator::DoAllocate()

NEW

+48

pw::allocator::BumpAllocator::BumpAllocator()

NEW

+48

pw::allocator::BumpAllocator::~BumpAllocator()

NEW

+20

pw::allocator::Deallocator::DoDeallocate()

NEW

+4

pw::allocator::BumpAllocator::kCapabilities

NEW

+2

pw::allocator::BumpAllocator::DoDeallocate()

+264

DualFirstFitBlockAllocator

FLASH

-4

quorem

+148

main

+104

pw::allocator::Block<>::SplitImpl()

+88

pw::allocator::Block<>::CrashIfInvalid()

+86

pw::allocator::Block<>::MergeNext()

-2

pw::allocator::Allocator::New<>()

-2

pw_boot_PreStaticMemoryInit

-4

p05.0

+16

pw::allocator::Block<>::Next()

+14

pw::allocator::Block<>::Prev()

+2

pw::allocator::internal::BaseUniquePtr::Deallocate()

NEW

+306

pw::allocator::DualFirstFitBlockAllocator<>::ChooseBlock()

NEW

+140

pw::allocator::Block<>::Resize()

NEW

+90

pw::allocator::BlockAllocator<>::DoDeallocate()

NEW

+88

pw::allocator::BlockAllocator<>::FromUsableSpace<>()

NEW

+68

pw::allocator::BlockAllocator<>

NEW

+68

pw::allocator::BlockAllocator<>::DoGetUsableLayout()

NEW

+68

pw::allocator::DualFirstFitBlockAllocator<>

NEW

+66

pw::allocator::BlockAllocator<>::DoGetAllocatedLayout()

NEW

+64

pw::allocator::DualFirstFitBlockAllocator<>::~DualFirstFitBlockAllocator()

NEW

+62

pw::allocator::BlockAllocator<>::DoResize()

NEW

+40

pw::allocator::BlockAllocator<>::DoAllocate()

NEW

+28

pw::allocator::BlockAllocator<>::UpdateLast()

NEW

+24

pw::AlignUp()

NEW

+22

pw::allocator::BlockAllocator<>::DoQuery()

NEW

+20

pw::allocator::internal::GenericBlockAllocator::CrashOnAllocated()

NEW

+16

pw::allocator::Block<>::Iterator::operator++()

NEW

+4

pw::allocator::BlockAllocator<>::DoGetCapacity()

NEW

+4

pw::allocator::internal::GenericBlockAllocator::kCapabilities

+1,624

FirstFitBlockAllocator

FLASH

-4

quorem

+144

main

+104

pw::allocator::Block<>::SplitImpl()

+88

pw::allocator::Block<>::CrashIfInvalid()

+86

pw::allocator::Block<>::MergeNext()

-2

pw::allocator::Allocator::New<>()

-2

pw_boot_PreStaticMemoryInit

-4

p05.0

+16

pw::allocator::Block<>::Next()

+14

pw::allocator::Block<>::Prev()

+2

pw::allocator::internal::BaseUniquePtr::Deallocate()

NEW

+158

pw::allocator::FirstFitBlockAllocator<>::ChooseBlock()

NEW

+140

pw::allocator::Block<>::Resize()

NEW

+90

pw::allocator::BlockAllocator<>::DoDeallocate()

NEW

+88

pw::allocator::BlockAllocator<>::FromUsableSpace<>()

NEW

+68

pw::allocator::BlockAllocator<>

NEW

+68

pw::allocator::BlockAllocator<>::DoGetUsableLayout()

NEW

+68

pw::allocator::FirstFitBlockAllocator<>

NEW

+66

pw::allocator::BlockAllocator<>::DoGetAllocatedLayout()

NEW

+64

pw::allocator::FirstFitBlockAllocator<>::~FirstFitBlockAllocator()

NEW

+62

pw::allocator::BlockAllocator<>::DoResize()

NEW

+40

pw::allocator::BlockAllocator<>::DoAllocate()

NEW

+28

pw::allocator::BlockAllocator<>::UpdateLast()

NEW

+24

pw::AlignUp()

NEW

+22

pw::allocator::BlockAllocator<>::DoQuery()

NEW

+20

pw::allocator::internal::GenericBlockAllocator::CrashOnAllocated()

NEW

+16

pw::allocator::Block<>::Iterator::operator++()

NEW

+4

pw::allocator::BlockAllocator<>::DoGetCapacity()

NEW

+4

pw::allocator::internal::GenericBlockAllocator::kCapabilities

+1,472

LastFitBlockAllocator

FLASH

+136

main

+104

pw::allocator::Block<>::SplitImpl()

+88

pw::allocator::Block<>::CrashIfInvalid()

+86

pw::allocator::Block<>::MergeNext()

-2

pw::allocator::Allocator::New<>()

-4

p05.0

+16

pw::allocator::Block<>::Next()

+14

pw::allocator::Block<>::Prev()

+2

pw::allocator::internal::BaseUniquePtr::Deallocate()

NEW

+148

pw::allocator::LastFitBlockAllocator<>::ChooseBlock()

NEW

+130

pw::allocator::Block<>::Resize()

NEW

+90

pw::allocator::BlockAllocator<>::DoDeallocate()

NEW

+88

pw::allocator::BlockAllocator<>::FromUsableSpace<>()

NEW

+68

pw::allocator::BlockAllocator<>

NEW

+68

pw::allocator::BlockAllocator<>::DoGetUsableLayout()

NEW

+68

pw::allocator::LastFitBlockAllocator<>

NEW

+66

pw::allocator::BlockAllocator<>::DoGetAllocatedLayout()

NEW

+64

pw::allocator::LastFitBlockAllocator<>::~LastFitBlockAllocator()

NEW

+60

pw::allocator::BlockAllocator<>::DoResize()

NEW

+40

pw::allocator::BlockAllocator<>::DoAllocate()

NEW

+28

pw::allocator::BlockAllocator<>::UpdateLast()

NEW

+22

pw::allocator::BlockAllocator<>::DoQuery()

NEW

+20

pw::allocator::internal::GenericBlockAllocator::CrashOnAllocated()

NEW

+4

pw::allocator::BlockAllocator<>::DoGetCapacity()

NEW

+4

pw::allocator::internal::GenericBlockAllocator::kCapabilities

+1,408

LibCAllocator

FLASH

+8

main

-2

pw_boot_PreStaticMemoryInit

NEW

+96

pw::allocator::FreeListHeap::Realloc()

NEW

+64

pw::allocator::LibCAllocator

NEW

+28

pw::allocator::LibCAllocator::DoReallocate()

NEW

+26

pw::allocator::LibCAllocator::DoAllocate()

NEW

+24

pw::allocator::LibCAllocator::DoDeallocate()

NEW

+20

__wrap_realloc

NEW

+16

pw::allocator::LibCAllocator::~LibCAllocator()

+280

WorstFitBlockAllocator

FLASH

+136

main

+104

pw::allocator::Block<>::SplitImpl()

+88

pw::allocator::Block<>::CrashIfInvalid()

+86

pw::allocator::Block<>::MergeNext()

-2

pw::allocator::Allocator::New<>()

-2

pw_boot_PreStaticMemoryInit

+16

pw::allocator::Block<>::Next()

+14

pw::allocator::Block<>::Prev()

+2

pw::allocator::internal::BaseUniquePtr::Deallocate()

NEW

+166

pw::allocator::WorstFitBlockAllocator<>::ChooseBlock()

NEW

+130

pw::allocator::Block<>::Resize()

NEW

+120

pw::allocator::Block<>::AdjustForAllocLast()

NEW

+90

pw::allocator::BlockAllocator<>::DoDeallocate()

NEW

+88

pw::allocator::BlockAllocator<>::FromUsableSpace<>()

NEW

+68

pw::allocator::BlockAllocator<>

NEW

+68

pw::allocator::BlockAllocator<>::DoGetUsableLayout()

NEW

+68

pw::allocator::WorstFitBlockAllocator<>

NEW

+66

pw::allocator::BlockAllocator<>::DoGetAllocatedLayout()

NEW

+64

pw::allocator::WorstFitBlockAllocator<>::~WorstFitBlockAllocator()

NEW

+60

pw::allocator::BlockAllocator<>::DoResize()

NEW

+40

pw::allocator::BlockAllocator<>::DoAllocate()

NEW

+28

pw::allocator::BlockAllocator<>::UpdateLast()

NEW

+22

pw::allocator::BlockAllocator<>::DoQuery()

NEW

+20

pw::allocator::internal::GenericBlockAllocator::CrashOnAllocated()

NEW

+4

pw::allocator::Block<>::kAlignment

NEW

+4

pw::allocator::BlockAllocator<>::DoGetCapacity()

NEW

+4

pw::allocator::internal::GenericBlockAllocator::kCapabilities

+1,552

Forwarding allocators implementations#

The following are code sizes for each of the provided “forwarding” allocators as described by Forwarding allocator concept. These are measured by having the forwarding allocator wrap a FirstFitBlockAllocator, and are measured relative to that implementation.

Label

Segment

Delta

FallbackAllocator

FLASH

+16

main

NEW

+74

pw::allocator::FallbackAllocator::DoAllocate()

NEW

+64

pw::allocator::FallbackAllocator

NEW

+64

pw::allocator::FallbackAllocator::DoGetAllocatedLayout()

NEW

+64

pw::allocator::FallbackAllocator::DoGetRequestedLayout()

NEW

+64

pw::allocator::FallbackAllocator::DoGetUsableLayout()

NEW

+48

pw::allocator::FallbackAllocator::DoDeallocate()

NEW

+44

pw::allocator::FallbackAllocator::FallbackAllocator()

NEW

+42

pw::allocator::FallbackAllocator::DoGetCapacity()

NEW

+36

pw::allocator::FallbackAllocator::DoResize()

NEW

+34

pw::allocator::FallbackAllocator::CombineResults()

NEW

+32

pw::allocator::Allocator::GetRequestedLayout()

NEW

+32

pw::allocator::Allocator::GetUsableLayout()

NEW

+26

pw::allocator::FallbackAllocator::DoQuery()

NEW

+26

pw::internal_result::StatusOrData<>::StatusOrData()

NEW

+24

pw::allocator::Allocator::Resize()

NEW

+16

pw::allocator::FallbackAllocator::~FallbackAllocator()

NEW

+6

pw::allocator::Deallocator::Query()

+712

SynchronizedAllocator<sync::InterruptSpinLock>

FLASH

+4

main

-2

pw::allocator::BlockAllocator<>::DoResize()

NEW

+64

pw::allocator::SynchronizedAllocator<>

NEW

+56

pw::allocator::SynchronizedAllocator<>::DoDeallocate()

NEW

+54

pw::allocator::SynchronizedAllocator<>::DoReallocate()

NEW

+48

pw::allocator::SynchronizedAllocator<>::DoAllocate()

NEW

+46

pw::allocator::Allocator::Reallocate()

NEW

+46

pw::allocator::SynchronizedAllocator<>::DoResize()

NEW

+44

pw::allocator::SynchronizedAllocator<>::DoQuery()

NEW

+44

pw::sync::Borrowable<>::acquire()

NEW

+42

pw::allocator::SynchronizedAllocator<>::DoGetAllocatedLayout()

NEW

+42

pw::allocator::SynchronizedAllocator<>::DoGetRequestedLayout()

NEW

+42

pw::allocator::SynchronizedAllocator<>::DoGetUsableLayout()

NEW

+40

pw::allocator::SynchronizedAllocator<>::DoGetCapacity()

NEW

+32

pw::allocator::Allocator::GetRequestedLayout()

NEW

+32

pw::allocator::Allocator::GetUsableLayout()

NEW

+24

pw::allocator::Allocator::Resize()

NEW

+16

pw::allocator::SynchronizedAllocator<>::~SynchronizedAllocator()

NEW

+14

pw::sync::BorrowedPointer<>::~BorrowedPointer()

+688

SynchronizedAllocator<sync::Mutex>

FLASH

+4

main

-2

pw::allocator::BlockAllocator<>::DoResize()

+2

pw_boot_PreStaticMemoryInit

NEW

+64

pw::allocator::SynchronizedAllocator<>

NEW

+56

pw::allocator::SynchronizedAllocator<>::DoDeallocate()

NEW

+54

pw::allocator::SynchronizedAllocator<>::DoReallocate()

NEW

+48

pw::allocator::SynchronizedAllocator<>::DoAllocate()

NEW

+46

pw::allocator::Allocator::Reallocate()

NEW

+46

pw::allocator::SynchronizedAllocator<>::DoResize()

NEW

+44

pw::allocator::SynchronizedAllocator<>::DoQuery()

NEW

+44

pw::sync::Borrowable<>::acquire()

NEW

+44

pw::sync::BorrowedPointer<>::~BorrowedPointer()

NEW

+42

pw::allocator::SynchronizedAllocator<>::DoGetAllocatedLayout()

NEW

+42

pw::allocator::SynchronizedAllocator<>::DoGetRequestedLayout()

NEW

+42

pw::allocator::SynchronizedAllocator<>::DoGetUsableLayout()

NEW

+40

pw::allocator::SynchronizedAllocator<>::DoGetCapacity()

NEW

+32

pw::allocator::Allocator::GetRequestedLayout()

NEW

+32

pw::allocator::Allocator::GetUsableLayout()

NEW

+24

pw::allocator::Allocator::Resize()

NEW

+16

pw::allocator::SynchronizedAllocator<>::~SynchronizedAllocator()

+720

TrackingAllocator<AllMetrics>

FLASH

+12

main

-2

pw::allocator::BlockAllocator<>::DoResize()

NEW

+360

pw::allocator::internal::Metrics<>::Metrics()

NEW

+216

pw::allocator::TrackingAllocator<>::DoReallocate()

NEW

+188

pw::allocator::TrackingAllocator<>::DoResize()

NEW

+156

pw::allocator::TrackingAllocator<>::~TrackingAllocator()

NEW

+142

pw::allocator::TrackingAllocator<>::DoAllocate()

NEW

+114

pw::allocator::TrackingAllocator<>::DoDeallocate()

NEW

+80

pw::allocator::internal::Metrics<>::ModifyAllocated()

NEW

+80

pw::allocator::internal::Metrics<>::ModifyRequested()

NEW

+76

pw::allocator::TrackingAllocator<>::FromUsableSpace<>()

NEW

+70

pw::allocator::TrackingAllocator<>::DoGetRequestedLayoutImpl()

NEW

+64

pw::allocator::TrackingAllocator<>

NEW

+54

pw::allocator::TrackingAllocator<>::DoGetUsableLayout()

NEW

+54

pw::allocator::TrackingAllocator<>::ReserveStorage()

NEW

+46

pw::allocator::Allocator::Reallocate()

NEW

+40

pw::allocator::TrackingAllocator<>::GetRequestedStorage()

NEW

+40

pw::metric::Metric::Increment()

NEW

+36

pw::metric::Metric::Decrement()

NEW

+32

pw::allocator::Allocator::GetRequestedLayout()

NEW

+32

pw::allocator::Allocator::GetUsableLayout()

NEW

+32

pw::intrusive_list_impl::List::insert_after()

NEW

+30

pw::allocator::internal::UnwrapLayout()

NEW

+28

pw::allocator::TrackingAllocator<>::DoGetAllocatedLayout()

NEW

+28

pw::allocator::TrackingAllocator<>::DoGetRequestedLayout()

NEW

+28

pw::allocator::internal::Metrics<>::RecordFailure()

NEW

+28

pw::metric::Metric::SetInt()

NEW

+28

pw::metric::Metric::as_int()

NEW

+26

pw::allocator::TrackingAllocator<>::SetRequested()

NEW

+24

pw::allocator::Allocator::Resize()

NEW

+24

pw::allocator::TrackingAllocator<>::ToUsableSpace()

NEW

+22

pw::intrusive_list_impl::List::Item::unlist()

NEW

+14

pw::intrusive_list_impl::List::Item::previous()

NEW

+14

pw::intrusive_list_impl::List::Item::~Item()

NEW

+8

pw::allocator::TrackingAllocator<>::DoGetCapacity()

NEW

+8

pw::allocator::TrackingAllocator<>::DoQuery()

+2,232

TrackingAllocator<NoMetrics>

FLASH

+12

main

-2

pw::allocator::BlockAllocator<>::DoResize()

-2

pw_log_tokenized_HandleLog

NEW

+88

pw::allocator::TrackingAllocator<>::DoReallocate()

NEW

+78

pw::allocator::TrackingAllocator<>::DoResize()

NEW

+64

pw::allocator::TrackingAllocator<>

NEW

+64

pw::allocator::TrackingAllocator<>::~TrackingAllocator()

NEW

+58

pw::allocator::TrackingAllocator<>::DoDeallocate()

NEW

+54

pw::allocator::TrackingAllocator<>::DoGetRequestedLayoutImpl()

NEW

+46

pw::allocator::Allocator::Reallocate()

NEW

+42

pw::allocator::TrackingAllocator<>::DoAllocate()

NEW

+32

pw::allocator::Allocator::GetRequestedLayout()

NEW

+32

pw::allocator::Allocator::GetUsableLayout()

NEW

+30

pw::allocator::internal::UnwrapLayout()

NEW

+24

pw::allocator::Allocator::Resize()

NEW

+20

pw::intrusive_list_impl::List::Item::unlist()

NEW

+14

pw::allocator::TrackingAllocator<>::DoGetAllocatedLayout()

NEW

+14

pw::allocator::TrackingAllocator<>::DoGetRequestedLayout()

NEW

+14

pw::allocator::TrackingAllocator<>::DoGetUsableLayout()

NEW

+14

pw::intrusive_list_impl::List::Item::previous()

NEW

+8

pw::allocator::TrackingAllocator<>::DoGetCapacity()

NEW

+8

pw::allocator::TrackingAllocator<>::DoQuery()

+712