Jump to content
php.lv forumi

Allowed memory size exhausted


EdgarsK

Recommended Posts

Notiek formas submit ar vairakiem foto

<?php
   for($i=0;$i<$photo_count;$i++){
     $image=$i.time().$i.".jpg";
     $this->upload($_FILES["create"]["tmp_name"]["photo"][$i],BASE."/images/products/$image");
     $this->thumb(BASE."/images/products/$image",BASE."/images/products/100-$image",100);
     $images.=($images ? ";" : "").$image;
   }
?>

klases funkcijas

<?php
   function upload($source,$dest) {
     copy($source,$dest);
     chmod($dest,0644);
   }
   function thumb($source,$dest,$tosize) {
     $size = getimagesize($source);
     $thumb_height = ( int )(($tosize/$size[0])*$size[1]);
     $thumbnail = ImageCreateTrueColor($tosize,$thumb_height);
     $src_img = ImageCreateFromJPEG($source);
     ImageCopyResampled($thumbnail,$src_img,0,0,0,0,$tosize,$thumb_height,$size[0],$size[1]);
     ImageJPEG($thumbnail, $dest);
     ImageDestroy($thumbnail);
     unset($size);
     unset($thumb_height);
     unset($thumbnail);
     unset($src_img);
   }
?>

 

Kļūdas ziņojums:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 14016 bytes) in F:\dev\engine\core.php on line 132

Kļūme: $src_image=ImageCreateFromJPEG($source);

 

Atgrāk bija tādi pati problēma, bet tad es pievienoju "unset" kas palīdzēja, bet tagad nepalīdz.

Edited by EdgarsA
Link to comment
Share on other sites

  • 1 month later...

Problema,

 

Lai cik lielu 'x' es liktu -> ini_set('memory_limit', 'xM');

 

Man visu laiku rāda to erroru ,tikai šādi:

 

Pāra skaitļiem: Allowed memory size of 16777216 bytes exhausted (tried to allocate 6144 bytes)

Nepāra: Allowed memory size of 15728640 bytes exhausted (tried to allocate 24576 bytes)

 

Kods kur tas notiek:

 

//x Menu
$queryMain = "SELECT * FROM items WHERE cateogry='x'";
$resultMain = db_query($queryMain);
$test = mysql_fetch_array($resultMain);
echo "<li><a href='index.php' onclick='return clickNode('r1n1')'>Iebūvējamie Ledusskapji</a>";
if ($test > 0)
	{

		echo "<ul id='r1n1'>";
			while($row = db_array($resultMain))
				{

					echo "<li><a href='show.php?id=".$row['id']."'".$row['name']."</a>";
               		echo "</li>";

				}
		echo "</ul>";
		echo "</li>";

	}
else
	{

		echo "</li>";

	}

//y Menu
$queryMain = "SELECT * FROM items WHERE cateogry='y'";
$resultMain = db_query($queryMain);
$test = mysql_fetch_array($resultMain);
echo "<li><a href='index.php' onclick='return clickNode('r2n1')'>Ledusskapji</a>";
if ($test > 0)
	{

		echo "<ul id='r2n1'>";
			while($row = db_array($resultMain))
				{

			echo "<li><ahref='show.php?id=".$row['id']."'".$row['name']."</a>"; //SAJA linijā errors
               		echo "</li>";

				}
		echo "</ul>";
		echo "</li>";

	}
else
	{

		echo "</li>";

	}

 

Esmu mēģinājis arī 200M ;D

 

 

[sOLVED] Man include("header.php"); bija iekš header.php ;D

Edited by masq
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...