Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Script eat HUGE amount of memory when run can see why!
Old 02-03-2008, 12:02 PM Script eat HUGE amount of memory when run can see why!
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Hi,

okay i was bored and was tryign to make a matrix like thing, with green text and marquees and used PHP for() loops abd stuff and random number generators..

but whenever i run it on local system everything crashes internet explorer's memory usage goes to unbelivavble amounts (INTO GB!!!!) eventually stops responding and everything just crashes.

the script:

PHP Code:
<?php
/* ********************************
Random String Generator
- used for forgot password script.
***********************************/
function assign_rand_value($num)
{
// accepts 1 - 36
  
switch($num)
  {
    case 
"1":
     
$rand_value "0";
    break;
    case 
"2":
     
$rand_value "1";
    break;
    case 
"3":
     
$rand_value "2";
    break;
    case 
"4":
     
$rand_value "3";
    break;
    case 
"5":
     
$rand_value "4";
    break;
    case 
"6":
     
$rand_value "5";
    break;
    case 
"7":
     
$rand_value "6";
    break;
    case 
"8":
     
$rand_value "7";
    break;
    case 
"9":
     
$rand_value "8";
    break;
    case 
"10":
     
$rand_value "9";
    break;
    case 
"11":
     
$rand_value "10";
    break;
    case 
"12":
     
$rand_value "11";
    break;
    case 
"13":
     
$rand_value "12";
    break;
    case 
"14":
     
$rand_value "13";
    break;
    case 
"15":
     
$rand_value "14";
    break;
    case 
"16":
     
$rand_value "15";
    break;
    case 
"17":
     
$rand_value "16";
    break;
    case 
"18":
     
$rand_value "17";
    break;
    case 
"19":
     
$rand_value "18";
    break;
    case 
"20":
     
$rand_value "19";
    break;
  }
return 
$rand_value;
}
/** Make String **/
function get_rand_string($length)
{
  if(
$length>0
  { 
  
$rand_id="";
   for(
$i=1$i<=$length$i++)
   {
   
mt_srand((double)microtime() * 1000000);
   
$num mt_rand(1,20);
   
$rand_id .= assign_rand_value($num);
   }
  }
return 
$rand_id;

function 
is_even($num){
  return (
$num%2) ? TRUE FALSE;
}
echo 
'<html>
<head> 
<style type="text/css">
body {
background: #000;
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>'
;
 for(
$i 0$i 105$i++)
 {
 
$speed get_rand_string(1);
 
$heightget_rand_string(2);
 
$no_chars get_rand_string(1);
  for(
$y 0$y $no_chars$y++)
  {
  
$char get_rand_string(1);
  
$brs get_rand_string(1);
   if(
$brs 4)
   {
   
$brs round($brs/4);
          for(
$x 0$x $brs$x++)
    {
    
$br .= '<br />';
    }
   
$chars .= $char.$br;
   }
   if(
$height 250)
   {
   
$height = ($height/4)*2;
   }
   echo 
'<marquee direction="';
    if(
is_even($char+$speed+$height))
    {
    echo 
'up';
    }
    else {
    echo 
'down" style=" vertical-align: top;';
    }
   echo 
'" style="color:#00CC00; background:#000000; margin:0px; padding:0px; float: left" width="10px" height="'.$height.'px" behavior="scroll" hspace="0" scrollamount="'.$speed.'">'.$chars.'</marquee>'."\n";
   
#echo '<span style="color:#fff">'.$height.'</span>';
  
}
 
 echo 
'<br />';
 }

echo 
'</body>
</html>'
;
?>
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 02-04-2008, 01:06 AM Re: Script eat HUGE amount of memory when run can see why!
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
This is definitely not a problem of php. If your code works well and produces the output of reasonable size then you should think of another way of rendering the obtained data into visual effects.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Script eat HUGE amount of memory when run can see why!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19901 seconds with 12 queries