Skip to content

fix tinythread memory leak #187

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

Merged
merged 5 commits into from
Oct 28, 2022
Merged

fix tinythread memory leak #187

merged 5 commits into from
Oct 28, 2022

Conversation

kevinushey
Copy link
Contributor

Closes #185. See also: #186

@dipterix, can you take a look and let me know what you think?

dipterix added a commit to dipterix/ravetools that referenced this pull request Oct 27, 2022
@dipterix
Copy link

dipterix commented Oct 27, 2022

I think this PR is pretty legit, much better than mine.

Also just FYI: Merged into ravetools version dipterix/ravetools@801068a

Tested on the following platform

  • MacOS (Intel & M2)
  • Linux (Docker, rocker)

The memory usage falls back once gc() is called.

In addition UBSAN-Clang check results:

# R -d "valgrind --tool=memcheck --leak-check=full" -f tmp.R
==13== Memcheck, a memory error detector
==13== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==13== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==13== Command: /usr/lib/R/bin/exec/R -f tmp.R
==13== 
> library(ravetools)
> 
> ravetools::fast_mvmedian(matrix(1:100,10))
 [1]  5.5 15.5 25.5 35.5 45.5 55.5 65.5 75.5 85.5 95.5
> 
> # testthat::test_dir('tests')
> # testthat::test_examples('.')
> 
> 
==13== 
==13== HEAP SUMMARY:
==13==     in use at exit: 52,590,480 bytes in 10,325 blocks
==13==   total heap usage: 29,524 allocs, 19,199 frees, 89,546,893 bytes allocated
==13== 
==13== LEAK SUMMARY:
==13==    definitely lost: 0 bytes in 0 blocks
==13==    indirectly lost: 0 bytes in 0 blocks
==13==      possibly lost: 0 bytes in 0 blocks
==13==    still reachable: 52,590,480 bytes in 10,325 blocks
==13==                       of which reachable via heuristic:
==13==                         newarray           : 4,264 bytes in 1 blocks
==13==         suppressed: 0 bytes in 0 blocks
==13== Reachable blocks (those to which a pointer was found) are not shown.
==13== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==13== 
==13== For lists of detected and suppressed errors, rerun with: -s
==13== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

@kevinushey kevinushey merged commit 878b6e7 into master Oct 28, 2022
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.

Memory leak
2 participants