-
Notifications
You must be signed in to change notification settings - Fork 299
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
Possible memory leak with ly_ctx_new / ly_ctx_destory #1569
Comments
What exactly is |
We create our own context. _yang_context is allocated memory during the initialization stage of our program like so: |
Could this be related to #15 ? |
Okay, so then I do not understand how is using libnetconf2 relevant. As long as you are creating your own context and not passing it to any libnetconf2 API, it must be completely independent. As for your print functions, it would seem that your process is crashing, which would explain the "possible" leak as well. Have you checked that? |
This issue is not related to libyang. |
@rabhat31 What was the issue and how did you fix this? I am facing something very similar and think I might be missing something in my implementation |
Hi,
We're using libyang v 1.0.225 and libnetconf2 v 1.1.26 in our codebase and run into a possible memory leak with ly_ctx_new().
Here is the loss record:
==2249== 17,035 bytes in 66 blocks are still reachable in loss record 2,274 of 2,457
==2249== at 0x4CA3E26: malloc (vg_replace_malloc.c:299)
==2249== by 0x79321EB: parse_text (xml.c:738)
==2249== by 0x7933AB9: lyxml_parse_elem (xml.c:1098)
==2249== by 0x79339F0: lyxml_parse_elem (xml.c:1082)
==2249== by 0x79339F0: lyxml_parse_elem (xml.c:1082)
==2249== by 0x79339F0: lyxml_parse_elem (xml.c:1082)
==2249== by 0x7934095: lyxml_parse_mem (xml.c:1231)
==2249== by 0x796131A: yin_read_module (parser_yin.c:7468)
==2249== by 0x799D8F9: lys_parse_mem_ (tree_schema.c:1080)
==2249== by 0x799DA04: lys_parse_mem (tree_schema.c:1112)
==2249== by 0x790CD39: ly_ctx_new (context.c:142)
I know for a fact that we're calling the destructor (within which we destroy the context) before the process terminates. The destructor is something like this:
...
nc_client_destroy();
ly_ctx_destroy(_yang_context, NULL);
...
The funny thing about this is the behavior of ly_ctx_destroy. I put in some print statements to check that the functions are being called correctly.
print0
nc_client_destroy();
print1
ly_ctx_destroy(_yang_context, NULL);
print2
I see print0 and print1 but print2 does not show up. I even switched the order of nc_client_destroy and ly_ctx_destroy but nothing after ly_ctx_destroy gets printed. I'm not really sure what could be causing this behavior. Please let me know if you have any suggestions.
Thanks
The text was updated successfully, but these errors were encountered: