php - Prevent my script from using so much memory? -


i have script lists possible permutations in array, which, admittedly, might used instead of wordlist. if work, it'll impossible not hit unless there limit on attempts.

anyway, script takes huge amount of memory, set server on fire. need finding way spread out memory usage, somehow resetting script , continuing left off going file or something, possibly using sessions. have no clue.

here's i've got far:

<?php  ini_set('memory_limit', '-1'); ini_set('max_execution_time', '0');  $possible = "abcdefghi";  $input = "$possible";  function string_getpermutations($prefix, $characters, &$permutations) {     if (count($characters) == 1)         $permutations[] = $prefix . array_pop($characters);     else     {         ($i = 0; $i < count($characters); $i++)         {             $tmp = $characters;             unset($tmp[$i]);              string_getpermutations($prefix . $characters[$i], array_values($tmp), $permutations);         }     } } $characters = array(); ($i = 0; $i < strlen($input); $i++)     $characters[] = $input[$i]; $permutations = array();  print_r($characters); string_getpermutations("", $characters, $permutations);  print_r($permutations);  ?> 

any ideas? :3

you store permutations in files every xxx permutations, reopen files when needed in correct order display/use permutations. (files or whatever want, long can free php memory)

i see you're echoing permutations, maybe you'd want else ? depends somehow.

also, try unset many unused variables possible while doing permutations.

edit : sometimes, using references did permutations array can result bigger use of memory. in case didn't try, check better, or without


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -