Thanks for your clear report of this serious bug. It will be fixed in the next beta,
On Thu, Jul 22, 2021 at 9:53 PM Ben Gorte <[email protected]> wrote: > Hi again, > > Yesterday I reported about recursive verbs with for loops leaking memory in > J903. > > I investigated a little bit further and it turns out that this happens in > any verb with a for loop. It has nothing to do with recursion (and indeed, > why would it?). Sorry for this confusion. > > My example is again trivial, and I do know that loops should generally be > avoided. But anyway: > > F =: 3 : 'for_i. i.8 do. y end.' > > W =: 3 : 'while. w < y do. F w=.w+1 end.' > > > w =: 0 > > 7!:2 'W 10' > > 11712 > > > w =. 0 > > 7!:2 'W 10000' > > 10241472 > > > It looks (to me) like 1024 bytes are leaked during each activation of F . > > > In j902 I get 2752, both times. > > > Ben > > > > On Thu, 22 Jul 2021 at 12:52, Ben Gorte <[email protected]> wrote: > > > G'day > > > > Below is an expensive method to compute powers of 8: > > > > RecFor =: 3 : 0 > > > > if. y = 0 do. > > > > z =. 1 > > > > else. > > > > z =. 0 > > > > for_i. i.8 do. > > > > z =. z + RecFor y-1 > > > > end. > > > > end. > > > > z > > > > ) > > > > > > RecFor 6 > > > > 262144 > > > > > > The concerning thing is about the amount of memory required for this: > > > > 7!:2 'RecFor 6' > > > > 38352128 > > > > 7!:2 'RecFor 7' > > > > 306788160 > > > > 7!:2 'RecFor 8' > > > > 2454272384 > > > > > > This happens in linux; I didn't try it in Windows at the office because > of > > lockdown. > > > > If I do this several times, the task (as seen in top) gets bigger and > > bigger. Looks like a genuine memory leak, doesn't it? > > > > > > As far as I can see this happens only when combining a recursive verb and > > a for loop -- not when using either of those separately (but that makes > it > > even more mysterious to me). > > > > JVERSION > > > > Engine: j903/j64avx2/linux > > > > Beta-k: commercial/2021-05-30T16:05:35 > > > > Library: 9.03.06 > > > > Qt IDE: 1.9.2/5.9.5(5.12.8) > > > > Platform: Linux 64 > > > > Installer: J903 install > > > > InstallPath: /home/ben/j903 > > > > Contact: www.jsoftware.com > > > > > > The good news is that I still have 902 around: > > > > > > 7!:2 'RecFor 5' > > > > 9344 > > > > 7!:2 'RecFor 6' > > > > 11008 > > > > 7!:2 'RecFor 7' > > > > 12672 > > > > > > I suppose the small increase is now due to the stack size, is it? > > > > > > Greetings, > > Ben > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
