Support » Fixing WordPress » Out of memory in media.php line 258

  • Hi there,
    I have a user-contributed news blog and it keeps on crashing due to an user uploading a image file which is simply very large.

    I get an

    Out of memory Error in media.php line 258

    I have searched the forum a few times but the suggestion to raise memory limit again and again is simply not a solution for me.

    The sofware should not crash and should not eat more and more memory, oterwise we’ve given to blog contributors an easy way to crash the site.
    A good software could simply avoid displaying/managing the image if it’s too large.

    I suggest a fix in media.php or some code somewhere else which limits using images too large (I am not talking here about file size, I mean image size in pixels, which has impact on memory eaten up)

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    Usual pixel size and file size go hand in hand. How large are we talking about?

    One of the images which crashed my blog is this one:


    size is 3872×2592

    Obviously, the user who uploaded it is a beginner and has used an image she got straight out from the photo camera.

    It seems that the system crashes while trying to compute a thumbnail of the image. Isn’t it possible to detect the image size without actually loading it in memory so that it proceeds only if the image has got a reasonable size?

    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    At 1.5 megs, it’s not the file size, sir! You are correct!

    But… It’s GD that’s doing the crunching, as I recall, and that’s probably what’s the problem. Ugh.

    I found this old plugin: it may be a good start?


    the plugin is a good idea indeed.

    I tried it, it partially solves the problem in the sense that it crashes exactly the same (most linkely it uses the same resize method) BUT the crashing message can be seen in the uploader window, so the effect is that the user cannot place the image and at least he’s got the preception he’s doing something wrong.

    I think however the software should not crash like this.
    If it was possible to check the image size beforehand and issue a “image too big” message before attempting to shrink it, it would be the best approach.

    Working on the plugin is better for me than to modify the core code – I will try this myself, thanks for putting me in the right direction.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Out of memory in media.php line 258’ is closed to new replies.