hello,
I just wonder why I cannot free the memory from a linear closure in ATS2.
I try this :
#include “share/atspre_staload_tmpdef.hats”
staload UN = “prelude/SATS/unsafe.sats”
implement main0() = let
val cl = lam (x:int): int = x + 2
val r = cl 78
val () = cloptr_free($UN.castvwtp0{cloptr0}(cl))
in
println! ("res is : ", r)
end
compile it through : patscc -o test_cloptr -DATS_MEMALLOC_LIBC
test_cloptr.dats
and run it with valgrind :
@ valgrind ./test_cloptr
==16486== Memcheck, a memory error detector
==16486== Copyright © 2002-2012, and GNU GPL’d, by Julian Seward et al.
==16486== Using Valgrind-3.8.0 and LibVEX; rerun with -h for copyright info
==16486== Command: ./test_cloptr
==16486==
res is : 80
==16486==
==16486== HEAP SUMMARY:
==16486== in use at exit: 4,112 bytes in 3 blocks
==16486== total heap usage: 4 allocs, 1 frees, 4,120 bytes allocated
==16486==
==16486== LEAK SUMMARY:
==16486== definitely lost: 16 bytes in 2 blocks
==16486== indirectly lost: 0 bytes in 0 blocks
==16486== possibly lost: 0 bytes in 0 blocks
==16486== still reachable: 4,096 bytes in 1 blocks
==16486== suppressed: 0 bytes in 0 blocks
==16486== Rerun with --leak-check=full to see details of leaked memory
==16486==
==16486== For counts of detected and suppressed errors, rerun with: -v
==16486== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 3)
We can clearly see that memory is not released. Am I missing something ?
I did look in ATS1 and it works fine…
thanks