Skip to content

Commit 7407c08

Browse files
committed
Refs #22841. Improve max_allocations calculation.
Signed-off-by: Miguel Company <[email protected]>
1 parent 8eb1072 commit 7407c08

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,16 @@ bool SharedMemTransport::init(
301301
{
302302
return false;
303303
}
304-
shared_mem_segment_ = shared_mem_manager_->create_segment(configuration_.segment_size(),
305-
configuration_.port_queue_capacity());
304+
uint32_t max_allocations = configuration_.segment_size() / configuration_.max_message_size();
305+
if ((configuration_.segment_size() % configuration_.max_message_size()) != 0)
306+
{
307+
++max_allocations;
308+
}
309+
if (configuration_.port_queue_capacity() > max_allocations)
310+
{
311+
max_allocations = configuration_.port_queue_capacity();
312+
}
313+
shared_mem_segment_ = shared_mem_manager_->create_segment(configuration_.segment_size(), max_allocations);
306314

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

0 commit comments

Comments
 (0)