I have a script that needs to loop 11390625x's.
But i've run into a problem with
1) the script times out
2) the script runs out of memory
I can fix it timeing out but I don't know what to do about memory.
I've given php 900 meg to use, but thats not enough. :cry:
So is there anything I can do with the code to make it free memory?
[syntax=php]$num[1] = 1;
$num[2] = 2;
$num[3] = 3;
$num[4] = 4;
$num[5] = 5;
$num[6] = 6;
$num[7] = 7;
$num[8] = 8;
$num[9] = 9;
$num[10] = "a";
$num[11] = "b";
$num[12] = "c";
$num[13] = "d";
$num[14] = "e";
$num[15] = "f";
$x=1;
$f=1;
$e=1;
$d=1;
$c=1;
$b=1;
$a=1;
$count=1;
while($x==1){
$arr[$count] = $num[$a].$num[$b].$num[$c].$num[$d].$num[$e].$num[$f];
if($f==15){$f=0; $e++;}
if($e==15){$e=0; $d++;}
if($d==15){$d=0; $c++;}
if($c==15){$c=0; $b++;}
if($b==15){$b=0; $a++;}
if($a==15){$x=0;}
$f++;
$count++;
}[/syntax]
Running out of memory.
Moderator: General Moderators
-
penguinboy
- Forum Contributor
- Posts: 171
- Joined: Thu Nov 07, 2002 11:25 am
You have BBcode and Smiles disabled in your Profile, i believe.
I suggest not putting a memory limit on php, it just gets annoying when you have an php app that needs more than you allowed.
Or do what i would do just set the execution time high, and a new processor/mem stick.
I suggest not putting a memory limit on php, it just gets annoying when you have an php app that needs more than you allowed.
Or do what i would do just set the execution time high, and a new processor/mem stick.
-
penguinboy
- Forum Contributor
- Posts: 171
- Joined: Thu Nov 07, 2002 11:25 am
[quote="volka"]what's the purpose of that?
(not what the snippet does but why you need $arr)[/quote]
I was try store 11390625 combinations of numbers and letters in an array.
But I decieded that probably wouldn't work.
[quote="Oromian"]You have BBcode and Smiles disabled in your Profile, i believe. :wink:
I suggest not putting a memory limit on php, it just gets annoying when you have an php app that needs more than you allowed.
Or do what i would do just set the execution time high, and a new [url=http://ebay.ca]processor/mem stick[/url]. 8)[/quote]
Yep I do.
I'll try not putting a memory limit.
(not what the snippet does but why you need $arr)[/quote]
I was try store 11390625 combinations of numbers and letters in an array.
But I decieded that probably wouldn't work.
[quote="Oromian"]You have BBcode and Smiles disabled in your Profile, i believe. :wink:
I suggest not putting a memory limit on php, it just gets annoying when you have an php app that needs more than you allowed.
Or do what i would do just set the execution time high, and a new [url=http://ebay.ca]processor/mem stick[/url]. 8)[/quote]
Yep I do.
I'll try not putting a memory limit.
-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
surely the only reason for doing that is hacking a lowercase 6 character password somewhere
wouldn't it be better to just step incrementally from zero and define a character instance resultant from the remainder of a powered base sixteen step and just use the returned string once before overwriting - at least the entire array would never need to be held in memory.
as there is a slight chance that you only want it to output possible combinations of hexadecimel colour references......
subnote: I echoed it as putting 12.58Meg+ into memory ('specially as a defined index array) is a trifle daft imo
wouldn't it be better to just step incrementally from zero and define a character instance resultant from the remainder of a powered base sixteen step and just use the returned string once before overwriting - at least the entire array would never need to be held in memory.
as there is a slight chance that you only want it to output possible combinations of hexadecimel colour references......
Code: Select all
ini_set('max_execution_time',600);
$strt = 0;
$stp = 16777216;
while($strt++ < $stp)
{
$str = substr('00000'.dechex($strt),-6);
echo $str.' * ';
}