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

Leaks file handle of model in labeling mode #26

Open
crawlserv opened this issue Aug 4, 2020 · 0 comments
Open

Leaks file handle of model in labeling mode #26

crawlserv opened this issue Aug 4, 2020 · 0 comments

Comments

@crawlserv
Copy link

When using a model to label some text, valgrind gave me:

==5332== HEAP SUMMARY:
==5332==     in use at exit: 472 bytes in 1 blocks
==5332==   total heap usage: 602,017 allocs, 602,016 frees, 1,352,158,567 bytes allocated
==5332== 
==5332== 472 bytes in 1 blocks are still reachable in loss record 1 of 1
==5332==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==5332==    by 0x4A6AAAD: __fopen_internal (iofopen.c:65)
==5332==    by 0x4A6AAAD: fopen@@GLIBC_2.2.5 (iofopen.c:86)
==5332==    by 0x10A7C8: main (in /home/ans/Downloads/postagger/c/wapiti)
==5332== 
==5332== LEAK SUMMARY:
==5332==    definitely lost: 0 bytes in 0 blocks
==5332==    indirectly lost: 0 bytes in 0 blocks
==5332==      possibly lost: 0 bytes in 0 blocks
==5332==    still reachable: 472 bytes in 1 blocks
==5332==         suppressed: 0 bytes in 0 blocks

It seems like this file handle is not closed:

FILE *file = fopen(mdl->opt->model, "r");

A simple fclose(file); after the following line should suffice:

mdl_load(mdl, file);

Cheers!

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