SebKrantz / collapse

Advanced and Fast Data Transformation in R
https://sebkrantz.github.io/collapse/
Other
627 stars 33 forks source link

Valgrind reports memory leak from match #580

Closed NicChr closed 1 month ago

NicChr commented 1 month ago

Hi, I noticed that when running valgrind on my package I'm getting a memory leak error that seems to be related to the "match_two_vectors" function in match.c

You can see the full output here https://github.com/NicChr/timeplyr/actions/runs/9187996747/job/25266845172 if you're interested but I've pasted a snippet of the valgrind output below.

==1857== 12,582,912 bytes in 3 blocks are definitely lost in loss record 3,975 of 3,977 ==1857== at 0x4849E60: calloc (vg_replace_malloc.c:1595) ==1857== by 0x49EB600: R_chk_calloc (memory.c:3526) ==1857== by 0x32FE2ADA: match_two_vectors (match.c:391) ==1857== by 0x495A6E5: R_doDotCall (dotcode.c:766) ==1857== by 0x499D690: bcEval_loop (eval.c:8691) ==1857== by 0x49B08D2: bcEval (eval.c:7524) ==1857== by 0x49B08D2: bcEval (eval.c:7509) ==1857== by 0x49B0C2A: Rf_eval (eval.c:1167) ==1857== by 0x49B2D6E: R_execClosure (eval.c:2398) ==1857== by 0x49B3BE6: applyClosure_core (eval.c:2311) ==1857== by 0x49B4648: Rf_applyClosure (eval.c:2333) ==1857== by 0x49FA122: dispatchMethod (objects.c:472) ==1857== by 0x49FA7F8: Rf_usemethod (objects.c:512)

SebKrantz commented 1 month ago

Thanks. I forgot a Free(h) at the end of the function to free the memory allocated by Calloc.