Skip to content

fix: move history_memory_policy outside leave_middleware_default_qos guard - #896

Draft
Functionhx wants to merge 1 commit into
ros2:rollingfrom
Functionhx:fix/datasharing-memory-policy
Draft

fix: move history_memory_policy outside leave_middleware_default_qos guard#896
Functionhx wants to merge 1 commit into
ros2:rollingfrom
Functionhx:fix/datasharing-memory-policy

Conversation

@Functionhx

Copy link
Copy Markdown

Prevent NotEnoughMemoryException crash when RMW_FASTRTPS_USE_QOS_FROM_XML=1 with data_sharing. Move history_memory_policy to always apply PREALLOCATED_WITH_REALLOC. Fixes #878.

When data_sharing is AUTOMATIC (default), the history_memory_policy was
only set to PREALLOCATED_WITH_REALLOC_MEMORY_MODE inside the block gated
by leave_middleware_default_qos. This meant users with default QoS
settings could hit NotEnoughMemoryException when the preallocated pool
was exhausted, because the policy was left at PREALLOCATED_MEMORY_MODE.

Move the assignment outside the conditional so it always applies.

Test plan: built and verified NotEnoughMemoryException no longer occurs
with default data_sharing AUTOMATIC configuration.

Signed-off-by: Functionhx <2994114386@qq.com>
@mergify

mergify Bot commented Jul 12, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@Functionhx
Functionhx marked this pull request as draft July 12, 2026 04:24
@Functionhx

Copy link
Copy Markdown
Author

Converted to draft. The current approach needs design discussion — unconditionally overriding XML-configured history_memory_policy conflicts with documented behavior. Will narrow scope to internal discovery endpoints only, or discuss correct approach with maintainers.

@MiguelCompany

Copy link
Copy Markdown
Collaborator

@Functionhx As you said, the behavior is currently documented here.

I agree that we may apply some custom logic for ros_discovery_info, since it is a topic over which the user has no control, but I am not sure if it is worth the effort.

In my honest opinion, if the user wants to enable datasharing, it should be done on specific topics, not as a default profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NotEnoughMemoryException crash at node init when RMW_FASTRTPS_USE_QOS_FROM_XML=1 with data_sharing AUTOMATIC (Humble / FastDDS 2.6.x)

2 participants