[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Fatal error: Out of memory
Romms
Здраствуйте! Столкнулся с проблемой
PHP
Fatal error: Out of memory (allocated 26476544) (tried to allocate 2592 bytes) in /virt/homes/ms1/htdocs/admin/addfoto_new.


вот фрагмент кода где выскакивает ошибка
PHP
/* Здесь  */ $imnew=imagecreatetruecolor($wnew, $hnew); 

    $imold
=imagecreatefromjpeg($_FILES["image"]["tmp_name"]);// старое изображение
         imagecopyresampled($imnew, $imold, 0,0,0,0,$wnew, $hnew, $wold, $hold);
                                                   
         imagejpeg
($imnew, '../foto/'.$id.'.jpg');// новое (normal) изображение


как я знаю стоит только изменить memory_limit в php.ini, НО ставил даже 512Мб - НЕПОМАГАЕТ!

Что делать?!



Спустя 2 дня, 18 часов, 40 секунд (11.05.2009 - 08:54) Oyeme написал(а):
Try this:
Add for example:

* memory_limit = 16M to your php.ini file (recommended, if you have access)
* ini_set('memory_limit', '16M'); to your sites/default/settings.php file
*php_value memory_limit 16M to your .htaccess file in the Drupal root


Спустя 4 часа, 34 секунды (11.05.2009 - 12:54) Romms написал(а):
я поставил
memory_limit = 128M в php.ini

когда ставлю
php_value memory_limit 16M в .htaccess (пробовал разные значения)
пишет
Цитата

Внутреннаяя ошибка сервера (500)

При выполнении запроса страницы http://ms1.ho.ua/admin/admin2.html на сервере возникла внутренняя ошибка. Пожалуйста, обращайтесь к администратору по адресу ms1-admin@s2.ho.ua.

Цитата
* ini_set('memory_limit', '16M'); to your sites/default/settings.php file

доступ к такому файлу я не имею


I put
memory_limit = 128M в php.ini

when put
php_value memory_limit 16M in .htaccess (tried different values)
write
Цитата

Internal Server Error (500)

When you request pages http://ms1.ho.ua/admin/admin2.html server encountered an internal error. Please contact the administrator at ms1-admin@s2.ho.ua.

Цитата
* ini_set('memory_limit', '16M'); to your sites/default/settings.php file

access to the file, I do not have

Спустя 21 час, 35 минут, 14 секунд (12.05.2009 - 10:29) Oyeme написал(а):
put echo memory_get_usage(); on the line just before the failing line.

ini_get('memory_limit'); -to show your real memory size.

Тебе старое изображение нужно?)
если нет избався от него.

Спустя 3 дня, 4 часа, 48 минут, 34 секунды (15.05.2009 - 15:18) Romms написал(а):
На вот этом фрагменте
Цитата

echo memory_get_usage();
echo ' - ';
echo ini_get('memory_limit');
echo '<br>';

$imnew=imagecreatetruecolor($wnew, $hnew);

echo memory_get_usage();
echo ' - ';
echo ini_get('memory_limit');
echo '<br>';

    $imold=imagecreatefromjpeg("tmp.jpg");// старое изображение

echo memory_get_usage();
echo ' - ';
echo ini_get('memory_limit');
echo '<br>';


выдает такое:
Цитата

89712 - 128M
4072696 - 128M

Fatal error: Out of memory (allocated 26476544) (tried to allocate 10368 bytes) in /virt/homes/ms1/htdocs/admin/addfoto_new.php on line 96

когда на локальном сервере:
Цитата
99168 - 128M
4057224 - 128M

При этом же фото...
Цитата
Тебе старое изображение нужно?)
если нет избався от него.

А как?


Спустя 59 минут, 41 секунда (15.05.2009 - 16:18) Oyeme написал(а):
старайся после работы делать $imold


imagedestroy($imnew);

для переменный Null,unset();

так ты осбобождаешь пямять.

если ты делаешь upload то попробуй

memory_limit 24M
post_max_size 20M .



PHP
<?php

// This is the temporary file created by PHP
$uploadedfile $_FILES['uploadfile']['tmp_name'];

// Create an Image from it so we can do the resize
$src imagecreatefromjpeg($uploadedfile);

// Capture the original size of the uploaded image
list($width,$height)=getimagesize($uploadedfile);

// For our purposes, I have resized the image to be
// 600 pixels wide, and maintain the original aspect
// ratio. This prevents the image from being "stretched"
// or "squashed". If you prefer some max width other than
// 600, simply change the $newwidth variable
$newwidth=600;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);

// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

// now write the resized image to disk. I have assumed that you want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename "images/"$_FILES['uploadfile']['name'];
imagejpeg($tmp,$filename,100);

imagedestroy($src);
imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request
// has completed.

Спустя 16 дней, 2 часа, 11 минут, 9 секунд (31.05.2009 - 18:29) Romms написал(а):
PHP
$src = imagecreatefromjpeg($uploadedfile);


Вот всё и падает... unsure.gif
кажется всё чищу...

Спустя 2 дня, 14 часов, 59 минут, 19 секунд (4.06.2009 - 09:28) Romms написал(а):
Большое спасибо Oyeme!!! Я уже добил этот скрипт!! biggrin.gif


Thank you Oyeme!!! I have made this script!! biggrin.gif
user posted image
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.