Skip to content

Commit

Permalink
Refs #22841. Improve max_allocations calculation.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Feb 21, 2025
1 parent 8eb1072 commit 7407c08
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,16 @@ bool SharedMemTransport::init(
{
return false;
}
shared_mem_segment_ = shared_mem_manager_->create_segment(configuration_.segment_size(),
configuration_.port_queue_capacity());
uint32_t max_allocations = configuration_.segment_size() / configuration_.max_message_size();
if ((configuration_.segment_size() % configuration_.max_message_size()) != 0)
{
++max_allocations;
}
if (configuration_.port_queue_capacity() > max_allocations)
{
max_allocations = configuration_.port_queue_capacity();
}
shared_mem_segment_ = shared_mem_manager_->create_segment(configuration_.segment_size(), max_allocations);

// Memset the whole segment to zero in order to force physical map of the buffer
auto buffer = shared_mem_segment_->alloc_buffer(configuration_.segment_size(),
Expand Down

0 comments on commit 7407c08

Please sign in to comment.