Recent Posts

Pages: [1] 2 3 ... 10
1
Code Challenges / Re: fibonacci(4784969)
« Last post by John on July 12, 2019, 07:13:11 PM »
undef is a variable type in SB.

The UNDEF statement will free any resources to the var(s) and set the var type to undef.

Making all the variables in the function LOCAL didn't help.
2
Code Challenges / Re: fibonacci(4784969)
« Last post by AIR on July 12, 2019, 06:56:43 PM »
John,
According to the docs, if you undef an array the memory allocated to it is freed.
Does the same apply to strings?
If so, maybe undef'ing the SB variables after printing the value of 'b' would address the leak that's occurring when you run the fibo example in an endless loop.
3
Code Challenges / Re: fibonacci(4784969)
« Last post by John on July 09, 2019, 10:59:58 PM »
That's good enough for me.
4
Code Challenges / Re: fibonacci(4784969)
« Last post by AIR on July 09, 2019, 06:46:06 PM »
IF you properly exit an sb app, the memory is released.

With most apps, if you send a sigkill to it while monitoring for leaks, you will see that some of the memory allocated is not properly released.

So, the 'problem' is that sb never gets the chance to release allocated memory because of an artificial non-real world test.

I've tested this with a loop of 100 iterations while monitoring with valgrind.  I didn't see the memory usage jump up to the extent that others have.  And memory was released at the end.

That's as far as I'm going with this.  If y'all feel that the module is problematic, then either provide a fix or don't use it.
5
Code Challenges / Re: fibonacci(4784969)
« Last post by John on July 09, 2019, 01:45:19 PM »
AIR wrote the GMP2 module and I don't know where he stands with the abnormal memory usage and GMP.  From my testing it doesn't look like a bug in SB.
6
Code Challenges / Re: fibonacci(4784969)
« Last post by jack on July 09, 2019, 01:23:50 PM »
Hi John
as I understand it, your GMP wrapper used SB strings, it seems to me, that perhaps the memory leak may be due, to perhaps inaccurate reporting of the strings memory usage.
in FB I not only overload the operators but setup constructors and destructors to allocate and deallocate the memory used by the mpfr type.
for example, DIM as mpfr x(100) would initialize all the elements of x from 0 to 100 to the set precision and after scope, clear all the elements.
7
Code Challenges / Re: fibonacci(4784969)
« Last post by John on July 09, 2019, 12:32:57 PM »
It might be worthwhile to see if your BIGINT library would work better than GMP.
8
Code Challenges / Re: fibonacci(4784969)
« Last post by jack on July 09, 2019, 03:01:40 AM »
I ran fibo in a loop, and as I understand, there are no leaks.
the reason for sum is so that the compiler won't optimize the loop out
Code: [Select]
dim as double t=timer
dim as mpfr b, sum
for i as integer=1 to 500
fib2(4784969, b)
sum+=b
next
print sum
print "elapsed time ";timer-t;" seconds"
9
Code Challenges / Re: fibonacci(4784969)
« Last post by John on July 08, 2019, 01:23:34 PM »
How others have been testing for leaks is run your fibo in a WHILE loop and watch for abnormal memory consumption.
10
Code Challenges / Re: fibonacci(4784969)
« Last post by jack on July 08, 2019, 06:38:41 AM »
John, to the best of my ability, I don't see any memory leaks
Pages: [1] 2 3 ... 10