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

Clearing buffer when disabled #35

Open
emiralpayar opened this issue May 28, 2024 · 0 comments
Open

Clearing buffer when disabled #35

emiralpayar opened this issue May 28, 2024 · 0 comments

Comments

@emiralpayar
Copy link

emiralpayar commented May 28, 2024

Hello,
I am trying to implement a functionality to the rosbag_snapshot package to clear the buffer when it is disabled by calling the enable_snapshot service by 'false' value. In the snapshotter.cpp file, I added clear to the enableCB( ) function, but when I check the memory usage, the node does not free the memory it allocates after disabling it. Any help about this would be appreciated. Thanks in advance.

bool Snapshotter::enableCB(std_srvs::SetBool::Request& req, std_srvs::SetBool::Response& res)
{
  boost::upgrade_lock<boost::upgrade_mutex> read_lock(state_lock_);
  if (req.data && writing_)  // Cannot enable while writing
  {
    res.success = false;
    res.message = "cannot enable recording while writing.";
    return true;
  }
  // Obtain write lock and update state if requested state is different from current
  if (req.data && !recording_)
  {
    boost::upgrade_to_unique_lock<boost::upgrade_mutex> write_lock(read_lock);
    resume();
  }
  else if (!req.data && recording_)
  {
    boost::upgrade_to_unique_lock<boost::upgrade_mutex> write_lock(read_lock);
    pause();
    clear(); // The part I added to the code !!
  }
  res.success = true;
  return true;
}
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

No branches or pull requests

1 participant