Describe the bug
Try this script:
Red []
recycle/off
b: reduce [o: object []]
probe stats
loop 1000000 [find/same b o]
probe stats
Output of May 28th build 36857eb87 and before:
2221848
2222324
0:00:00.470027
Current build 3d23acd0f:
2240204
234240912
0:00:01.33608
Expected behavior
Stable memory usage.
Platform version (please complete the following information)
Red 0.6.4 for Windows built 8-Jun-2020/20:17:38
@qtxie Please have a look to see which commit caused that.
It is caused by the copying of the call value on the stack, so that the arguments cache datastructures are linked to the value on the stack instead of the original value, resulting in losing the cache once the call ends, and having to rebuild it at every next call.
@dockimbel we are in the new chapter of the saga... ;)
Red []
; 1 % 2 - 3 ;) spell of protection
recycle/off
ix: random collect [repeat i 10000 [keep i]]
print ["here" stats / 1e6 "M"]
sort/compare ix func [a b][loop 10 [1 - 1] a <= b]
print ["there" stats / 1e6 "M"]
recycle
print "freed"
Output:
here 3.110888 M
there 328.279812 M
freed
Red []
; 1 % 2 - 3 ;) spell of protection
recycle/off
ix: random collect [repeat i 50000 [keep i]]
print ["here" stats / 1e6 "M"]
parse/trace ix [any skip] func [e m r y s][
loop 10 [1 - 1]
yes
]
print ["there" stats / 1e6 "M"]
recycle
print "freed"
Output:
here 4.683952 M
there 352.695444 M
freed
Red []
; 1 % 2 - 3 ;) spell of protection
recycle/off
ix: append/dup "" "1 " 10000
print ["here" stats / 1e6 "M"]
transcode/trace ix func [e i t l k][
loop 10 [1 - 1]
yes
]
print ["there" stats / 1e6 "M"]
recycle
print "freed"
Output:
here 2.64916 M
there 72.413856 M
freed
All is not lost however, for the pure of heart may uncomment the spell at line 2 and banish the undying bug away ☻
If only we believed in magic. :^) :+1:
_Expecto patronum_ ... fixed!
I had to loo up _Expecto patronum_, which was good because I guessed its meaning incorrectly. I thought it meant that Nenad expected me to send him a bottle of Patrón for fixing the bug.
Most helpful comment
_Expecto patronum_ ... fixed!