algorithm - PHP memory size issue -
hello need analyze around 50,063,860 combinations fantasy roster. it's 60 pick 6.
i trying generate possible combinations passing names array math_combinatorics pearl library:
$n array of 60 elements,
$result = $combinatorics->combinations( $n, 6);
fatal error: allowed memory size of 2147483648 bytes exhausted (tried allocate 72 bytes) in /usr/share/php/math/combinatorics.php on line 126
is there anyway allocate more memory or feed less entries @ 1 time not crash?
you can increase memory_limit
in php.ini
. php docs:
this sets maximum amount of memory in bytes script allowed allocate. helps prevent poorly written scripts eating available memory on server. note have no memory limit, set directive -1.
you can set value inline in script using ini_set()
function or in apache virtual host configuration using php_value
directive.
having said that, behoove refactor code such not permutations need in memory @ once, thereby drastically reducing program's memory footprint.
Comments
Post a Comment