BASIC User Group > Code Challenges

fibonacci(4784969)

<< < (21/22) > >>

jack:
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.

John:
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.

AIR:
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.

John:
That's good enough for me.

AIR:
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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version