A much simpler way to check if memory leaks with `orc` is by using 
`-d:useMalloc` together with `valgrind`:
    
    
    import std/sugar
    
    import decimal/decimal
    
    proc main() =
        let constDcm = newDecimal("0.15")
        var newRange = collect(for x in 0..<5: constDcm + 1)
        
        # Operation which leaks memory with --gc:orc,
        # but does not leak memoryy with --gc:refc
        # Note - need the add operation with
        # a Decimal in collect() below
        newRange = collect(for x in 0..<5: constDcm + 1)
    
    main()
    
    
    Run

And GC_fullCollect() isn't needed for when you have no cycles, so you can 
actually test with ARC:

`nim c -d:danger -d:useMalloc --gc:arc ttaa.nim`
    
    
    ==12848== LEAK SUMMARY:
    ==12848==    definitely lost: 1,008 bytes in 21 blocks
    ==12848==    indirectly lost: 336 bytes in 21 blocks
    ==12848==      possibly lost: 0 bytes in 0 blocks
    ==12848==    still reachable: 0 bytes in 0 blocks
    ==12848==         suppressed: 0 bytes in 0 blocks
    
    
    Run

The leaks do seem to exist, but I think they actually come from the C code 
decimal uses, I'll try to investigate more.

Reply via email to