Code size analysis#

pw_allocator: Flexible, safe, and measurable memory allocation

This module provides the pw::allocator::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 pw::allocator::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<>()

+164

main

+4

p05.0

NEW

+276

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

NEW

+64

pw::allocator::NullAllocator

NEW

+38

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

NEW

+38

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

NEW

+24

pw::allocator::Allocator::DoGetRequestedLayout()

NEW

+22

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

NEW

+22

pw::allocator::Allocator::DoGetUsableLayout()

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::Deallocate()

NEW

+10

pw::allocator::Allocator::Deallocate()

NEW

+8

operator delete()

NEW

+6

pw::allocator::Allocator::DoGetCapacity()

NEW

+6

pw::allocator::Allocator::DoQuery()

NEW

+4

pw::allocator::NullAllocator::kCapabilities

+792

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

+4

quorem

+152

main

+104

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

+88

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

+86

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

-2

pw::allocator::Allocator::DoGetRequestedLayout()

+16

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

+14

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

NEW

+168

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

NEW

+130

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

NEW

+120

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

NEW

+90

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

NEW

+88

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

NEW

+68

pw::allocator::BestFitBlockAllocator<>

NEW

+68

pw::allocator::internal::BlockAllocator<>

NEW

+68

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

NEW

+66

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

NEW

+64

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

NEW

+62

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

NEW

+40

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

NEW

+28

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

NEW

+22

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

NEW

+20

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

NEW

+4

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

NEW

+4

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

NEW

+4

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

+1,576

DualFirstFitBlockAllocator

FLASH

+168

main

+104

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

+88

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

+86

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

-2

pw::allocator::Allocator::DoGetRequestedLayout()

-4

p05.0

+16

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

+14

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

NEW

+308

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

NEW

+140

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

NEW

+90

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

NEW

+88

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

NEW

+68

pw::allocator::DualFirstFitBlockAllocator<>

NEW

+68

pw::allocator::internal::BlockAllocator<>

NEW

+68

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

NEW

+66

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

NEW

+64

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

NEW

+60

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

NEW

+40

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

NEW

+28

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

NEW

+24

pw::AlignUp()

NEW

+22

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

NEW

+20

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

NEW

+16

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

NEW

+4

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

NEW

+4

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

+1,648

FirstFitBlockAllocator

FLASH

+4

quorem

+160

main

+104

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

+88

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

+86

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

-2

pw::allocator::Allocator::DoGetRequestedLayout()

-4

p05.0

+16

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

+14

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

NEW

+160

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

NEW

+140

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

NEW

+90

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

NEW

+88

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

NEW

+68

pw::allocator::FirstFitBlockAllocator<>

NEW

+68

pw::allocator::internal::BlockAllocator<>

NEW

+68

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

NEW

+66

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

NEW

+64

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

NEW

+60

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

NEW

+40

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

NEW

+28

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

NEW

+24

pw::AlignUp()

NEW

+22

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

NEW

+20

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

NEW

+16

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

NEW

+4

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

NEW

+4

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

+1,496

LastFitBlockAllocator

FLASH

+152

main

+104

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

+88

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

+86

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

-2

pw::allocator::Allocator::DoGetRequestedLayout()

-4

p05.0

+16

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

+14

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

NEW

+148

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

NEW

+130

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

NEW

+90

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

NEW

+88

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

NEW

+68

pw::allocator::LastFitBlockAllocator<>

NEW

+68

pw::allocator::internal::BlockAllocator<>

NEW

+68

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

NEW

+66

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

NEW

+64

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

NEW

+62

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

NEW

+40

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

NEW

+28

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

NEW

+22

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

NEW

+20

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

NEW

+4

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

NEW

+4

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

+1,424

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

+4

quorem

+152

main

+104

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

+88

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

+86

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

-2

pw::allocator::Allocator::DoGetRequestedLayout()

+16

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

+14

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

NEW

+168

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

NEW

+130

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

NEW

+120

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

NEW

+90

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

NEW

+88

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

NEW

+68

pw::allocator::WorstFitBlockAllocator<>

NEW

+68

pw::allocator::internal::BlockAllocator<>

NEW

+68

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

NEW

+66

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

NEW

+64

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

NEW

+62

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

NEW

+40

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

NEW

+28

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

NEW

+22

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

NEW

+20

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

NEW

+4

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

NEW

+4

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

NEW

+4

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

+1,576

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

-30

pw::allocator::SizeReporter::Measure()

+48

main

NEW

+84

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

NEW

+84

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

NEW

+84

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

NEW

+64

pw::allocator::FallbackAllocator

NEW

+48

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

NEW

+42

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

NEW

+36

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

NEW

+34

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

NEW

+32

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

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::Allocator::Query()

+688

SynchronizedAllocator<sync::InterruptSpinLock>

FLASH

-4

main

-4

quorem

+2

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

NEW

+64

pw::allocator::SynchronizedAllocator<>

NEW

+64

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

NEW

+64

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

NEW

+56

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

NEW

+48

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

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

+40

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

NEW

+32

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

NEW

+24

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

NEW

+16

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

NEW

+14

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

+592

SynchronizedAllocator<sync::Mutex>

FLASH

-4

main

-2

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

+2

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

NEW

+64

pw::allocator::SynchronizedAllocator<>

NEW

+64

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

NEW

+64

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

NEW

+56

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

NEW

+48

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

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

+40

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

NEW

+32

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

NEW

+24

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

NEW

+16

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

+624

TrackingAllocator<AllMetrics>

FLASH

-64

main

-4

quorem

-2

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

NEW

+360

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

NEW

+216

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

NEW

+188

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

NEW

+156

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

NEW

+142

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

NEW

+114

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

NEW

+104

pw::allocator::internal::BlockAllocator<>::Init()

NEW

+90

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

NEW

+80

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

NEW

+80

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

NEW

+76

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

NEW

+64

pw::allocator::TrackingAllocatorImpl<>

NEW

+54

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

NEW

+54

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

NEW

+46

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

NEW

+40

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

NEW

+40

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

NEW

+36

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

NEW

+32

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

NEW

+32

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

NEW

+32

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

NEW

+30

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

NEW

+30

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

NEW

+28

pw::allocator::TrackingAllocatorImpl<>::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::TrackingAllocatorImpl<>::SetRequested()

NEW

+24

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

NEW

+24

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

NEW

+22

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

NEW

+16

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

NEW

+14

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

NEW

+8

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

NEW

+8

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

+2,280

TrackingAllocator<NoMetrics>

FLASH

-64

main

-2

pw_log_tokenized_HandleLog

+2

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

NEW

+104

pw::allocator::internal::BlockAllocator<>::Init()

NEW

+88

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

NEW

+78

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

NEW

+74

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

NEW

+64

pw::allocator::TrackingAllocatorImpl<>

NEW

+64

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

NEW

+58

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

NEW

+46

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

NEW

+42

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

NEW

+34

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

NEW

+32

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

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::TrackingAllocatorImpl<>::DoGetAllocatedLayout()

NEW

+14

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

NEW

+14

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

NEW

+8

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

NEW

+8

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

+752