Jump to content

Recommended Posts

I am having an odd issue with imagecreatefrompng since I upgraded to 5.2.3.  It is possible the issue below has nothing to do with it, but that is the major difference.

 

Using imagecreatefrompng on an image that is 1.5 MB, the max memory using is 143 MB.  On one that is 16 MB, it is 187 MB.

 

Has anybody had anything similar happen with this?

 

A few months ago, I ran a similar script on a 10MB image, and I did not exceed even 16MB.  I would assume the memory should be much, much lower.

Link to comment
https://forums.phpfreaks.com/topic/63271-imagecreatefrompng-memory-issue/
Share on other sites

php loads the image into memory as a bitmap.  considering PNG's compression, a 10mb png could easily be a 100mb bitmap- its just that good.

 

my suggestion?  use smaller images.

 

the fact, though, that 1.5 -> 143 leads me to beleive that there is another issue or a memory leak going on.

I cannot use smaller images for this application.  They have to be huge.

 

Thanks for the compression point.  I always thought there were compressionless, but I just realized the compression is lossless, but they still do compress.

 

IF there is a memory leak, it is in the imagecreatefrompng function itself.  I do calls before and after that function, and that is where it goes way up.

 

$myMem=memory_get_peak_usage (true);
$myMem=$myMem/1000000;
print "max memory is $myMem MB before imagecreate<P>"; //here it is .25MB

$img_src = imagecreatefrompng( $sourcefile );

$myMem=memory_get_peak_usage (true);
$myMem=$myMem/1000000;
print "max memory is $myMem MB<P> after imagecreate";//here it is 140+MB

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.