-
Notifications
You must be signed in to change notification settings - Fork 293
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 #15
Comments
We know about this, but it seems that the destructor registered with pthread_key_create() is The issue is always on the main thread, thread-specific data in other threads are freed correctly. |
Ok, I'll workaround it with valgrind suppression file
|
It wasn't actually a real memory leak, there was just still reachable dynamically allocated memory on process exit, because the destructor registered by pthread_key_create() in the main thread isn't executed on process termination but only on thread termination (i.e. on pthread_exit()). So, on Linux, we are going to use static memory for the main thread's ly_errno. Fixes #15
The workaround with valgrind suppression file shouldn't be no more necessary on Linux. I have added Linux specific (non-portable) code to use static memory in case of the main thread. It shouldn't change functionality in any way, it is supposed just to suppress the valgrind message. |
The leak has returned in 2f83dc8 It appears if it the variable is initialized in a thread. Previous commit 843f419 works ok. 24: ==23881== 4 bytes in 1 blocks are definitely lost in loss record 1 of 5 |
Since pthread_once() is called only once in a process, also the destructor in pthread_key_create() is the same for all threads. But we use dynamic memory for threads and static memory for the main thread. Therefore, we have to check in destructor (and we cannot use standard free()) for freeing static memory if someone will use pthread_exit() in main(). Fixes #15
Since pthread_once() is called only once in a process, also the destructor in pthread_key_create() is the same for all threads. But we use dynamic memory for threads and static memory for the main thread. Therefore, we have to check in destructor (and we cannot use standard free()) for freeing static memory if someone will use pthread_exit() in main(). Fixes #15
Thanks Lukas, should work now. |
Yes, it does. Thanks |
It wasn't actually a real memory leak, there was just still reachable dynamically allocated memory on process exit, because the destructor registered by pthread_key_create() in the main thread isn't executed on process termination but only on thread termination (i.e. on pthread_exit()). So, on Linux, we are going to use static memory for the main thread's ly_errno. Fixes #15
Since pthread_once() is called only once in a process, also the destructor in pthread_key_create() is the same for all threads. But we use dynamic memory for threads and static memory for the main thread. Therefore, we have to check in destructor (and we cannot use standard free()) for freeing static memory if someone will use pthread_exit() in main(). Fixes #15
When targetting leaflist, its value must be specified as key (predicate) in the XPath expression. Fixes CESNET#15
When targetting leaflist, its value must be specified as key (predicate) in the XPath expression. Fixes CESNET#15
==23495== HEAP SUMMARY:
==23495== in use at exit: 4 bytes in 1 blocks
==23495== total heap usage: 1,536 allocs, 1,535 frees, 149,576 bytes allocated
==23495==
==23495== 4 bytes in 1 blocks are still reachable in loss record 1 of 1
==23495== at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23495== by 0x4E44502: ly_errno_location (common.c:58)
==23495== by 0x4E5F970: lyxml_parse_mem (xml.c:1131)
==23495== by 0x4E85CE4: yin_read_module (parser_yin.c:5300)
==23495== by 0x4E901BC: lys_parse_mem (tree_schema.c:1057)
==23495== by 0x4E4607E: ly_ctx_new (context.c:87)
==23495== by 0x400705: main (main.c:7)
==23495==
==23495== LEAK SUMMARY:
==23495== definitely lost: 0 bytes in 0 blocks
==23495== indirectly lost: 0 bytes in 0 blocks
==23495== possibly lost: 0 bytes in 0 blocks
==23495== still reachable: 4 bytes in 1 blocks
==23495== suppressed: 0 bytes in 0 blocks
==23495==
The text was updated successfully, but these errors were encountered: