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

Memory leak after undeclaring publisher, subscriber and closing session with c bindings #438

Open
hguelle opened this issue Jun 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@hguelle
Copy link

hguelle commented Jun 11, 2024

Describe the bug

I have some google tests which also checks the memory leaks. Tests open basically a session and create a publisher and a subscriber. After the test they should be cleaned up again. For that, I am using :

  • int8_t z_undeclare_publisher(struct z_owned_publisher_t *publisher);
  • int8_t z_undeclare_subscriber(struct z_owned_subscriber_t *sub);
  • int8_t z_close(struct z_owned_session_t *session);

These are all returning 0 as ret val. But after the test

To reproduce

  1. Start a session
  2. declare publisher
  3. declare subscriber
  4. undeclare publisher
  5. undeclare subscriber
  6. close session
  7. memory leak detected

memory_leaks.txt

System info

Debian x86_64 GNU/Linux

@hguelle hguelle added the bug Something isn't working label Jun 11, 2024
@DenisBiryukov91
Copy link
Contributor

These memory "leaks" come from rust static variables (namely ZRuntimePool) which are never dropped.
Rust does not drop static variables by design.
We have an API to force-drop ZRuntimePool to prevent corresponding memory leaks from appearing in the logs, but it is only available in zenoh-rust. We will likely provide similar api for zenoh-c/zenoh-c++ for the next release.

@DenisBiryukov91
Copy link
Contributor

@hguelle If possible, could you check the dev/1.0.0 version and call zc_stop_z_runtime() at the end of your program and let us know if you still get memory leaks reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants