Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix memory management issues when passing config to observer library #1952

Closed

Conversation

yyuuttaaoo
Copy link
Collaborator

Refactor configuration management to ensure memory consistency:

Move both construction and destruction of config to the application side to avoid new/free mismatch errors.
Use pointers instead of static objects to prevent premature destruction after library unloading.

bool ret = false;
auto eBPFConfig = std::make_unique<nami::eBPFConfig>();
eBPFConfig->plugin_type_ = type;
eBPFConfig->stats_handler_ = [this](auto stats){ return mMonitorMgr->HandleStatistic(std::move(stats)); };
eBPFConfig->stats_handler_ = [this](auto&& stats) { return mMonitorMgr->HandleStatistic(std::move(stats)); };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using NamiStatisticsHandler = std::function<void(std::vector&)>;

image

@yyuuttaaoo yyuuttaaoo closed this Dec 10, 2024
@yyuuttaaoo
Copy link
Collaborator Author

merged in #1951

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.

3 participants