GMP functions didn't free memory

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


  I'm using gmp library to perform a function which uses a few
operations with large integer values. My script runs in console mode
(at least four hours of processing), scanning a big mysql table and
invoking the function to calculate big integer values that are stored
in the table.

  But, in case the table has a lot of rows to process, the script halt
with 'out of memory' error. Studying the problem I realized that GMP
functions didn't free memory and continue allocate memory in every
function pass. There is no gmp_free() in php manual.

  Is there any workaround to avoid the problem?

  Thank you,

Sebastián Araya
Numisys S.A.

Re: GMP functions didn't free memory

Quoted text here. Click to load it

You could always unset the variable after you are done with it.  This
should have the garbage collector come through and fix that issue.

It's pretty much like reading a csv file... You should only read the
data in parts and process it in parts.

Also you should be able to modify the extension to add in gmp_free() if
it is an open source project.  It is really not to hard.  Zend has a
great tutorial on this.


Re: GMP functions didn't free memory


  thanks for your answer. I have tested it with unset(), but it doesn't
free the resource...

  I have maked some changes in portage source (I'm using Linux Gentoo),
verifying that _php_gmp_free() was declared but never used in
ext/gmp/gmp.c... sadly, right now, I'm running out of time to make
myself the write of the prototype function which wraps _php_gmp_free()
and test it.

  I'm posting as a bug in php (#33249), and reducing the record
processing to a half in order to "chunk" the problem and find a


Site Timeline