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

fix memory leak #5

Merged

Conversation

default-writer
Copy link
Contributor

No description provided.

@default-writer
Copy link
Contributor Author

default-writer commented Sep 3, 2020

Example project:

https://github.com/funcelot/c

before:

==19423==
==19423== HEAP SUMMARY:
==19423== in use at exit: 392 bytes in 1 blocks
==19423== total heap usage: 35 allocs, 34 frees, 2,616 bytes allocated
==19423==
==19423== 392 bytes in 1 blocks are definitely lost in loss record 1 of 1
==19423== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==19423== by 0x10B7F7: rx__run_test_cases (rexo.h:4846)
==19423== by 0x10BA9C: rx__run_registered_test_cases (rexo.h:4918)
==19423== by 0x10FC53: rx_run (rexo.h:6044)
==19423== by 0x110734: main (main.c:295)
==19423==
==19423== LEAK SUMMARY:
==19423== definitely lost: 392 bytes in 1 blocks
==19423== indirectly lost: 0 bytes in 0 blocks
==19423== possibly lost: 0 bytes in 0 blocks
==19423== still reachable: 0 bytes in 0 blocks
==19423== suppressed: 0 bytes in 0 blocks
==19423==
==19423== For lists of detected and suppressed errors, rerun with: -s
==19423== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

after:

==16591==
==16591== HEAP SUMMARY:
==16591== in use at exit: 0 bytes in 0 blocks
==16591== total heap usage: 35 allocs, 35 frees, 2,616 bytes allocated
==16591==
==16591== All heap blocks were freed -- no leaks are possible
==16591==
==16591== For lists of detected and suppressed errors, rerun with: -s
==16591== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

@default-writer default-writer mentioned this pull request Sep 3, 2020
@@ -4890,6 +4890,8 @@ rx__run_test_cases(size_t test_case_count,
rx_summary_terminate(&summaries[i]);
}

RX_FREE(summaries);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

summaries is never freed up, so thats a memory leak

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks @funcelot!

@christophercrouzet christophercrouzet merged commit 76f47c9 into christophercrouzet:master Sep 4, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants