php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47016 how to free a gmp resources?
Submitted: 2009-01-06 09:49 UTC Modified: 2009-01-06 12:19 UTC
From: smallhorst at gmail dot com Assigned:
Status: Not a bug Package: GNU MP related
PHP Version: 5.3.0alpha3 OS: fedora 9
Private report: No CVE-ID: None
 [2009-01-06 09:49 UTC] smallhorst at gmail dot com
Description:
------------
How to free gmp resources?
i need a function like gmp_free() to free gmp resources.

Reproduce code:
---------------
<?
function M($p){
return gmp_sub(gmp_pow(2,$p),1);
}
function S($i){
 for($tmm=4,$j=0;$j<$i;$j++){
  $tm1=gmp_pow($tmm,2);//gmp does not free memery,that is problem
  $tm2=gmp_sub($tm1,2);
  $tmm=$tm2;
 }
 return $tmm;
}
$p=31;
echo $mp=gmp_strval(M($p));
if(0==gmp_strval(gmp_mod(S($p-2),$mp))){echo 'yes';}else{echo 'no';}
?>

Expected result:
----------------
it should output a 'yes' or 'no'.
need it tell me : is the number a prime number

Actual result:
--------------
[kee212@localhost ecc]$ php c.php
2147483647PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 335806464 bytes) in /var/www/html/kee212/ecc/c.php on line 8

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 335806464 bytes) in /var/www/html/kee212/ecc/c.php on line 8



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-06 12:18 UTC] scottmac@php.net
Before it does on my system its trying to do a 19,191,376 digit number to the power of 2. This is using all of the memory, since GMP uses the PHP memory allocation functions we correctly report back what line it is.

Just to test I wrote a quick gmp_destroy() function and it got just as far.
 [2009-01-06 12:19 UTC] scottmac@php.net
Not a PHP bug -> Bogus
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 08:01:26 2019 UTC