Re:How to Fix PHP's Most Annoying Error
by martin_ on Tuesday September 16, 2014 @12:11PM
(#8325218)
Setting a 1gb memory limit is a great way to hide the problem and dramatically reduce the maximum number of concurrent requests to your website, and drain resources from any other services running on the box(es).
[ Parent
| on HN ]
Re:How to Fix PHP's Most Annoying Error
by laumars on Tuesday September 16, 2014 @12:59PM
(#8325488)
Being massively pedantic for a moment; he didn't set the memory limit to 1GB but instead to 0.9765625GB:
<?php
ini_set('memory_limit', '1000M'); // or you could use 1G
?>
Joking aside, do most people these days just use MB (1000^n) instead of MiB (1024^n) when working with RAM? Is this now the standard way to calculating memory?
Re:How to Fix PHP's Most Annoying Error
by 2upmedia on Tuesday September 16, 2014 @03:39PM
(#8326647)
Good call. Minor oversight. Just updated that. I think if your NOT a hardcore technologist you probably think of megabytes as as 1000^n. It's really easy to forget too for the rest of us.
Re:How to Fix PHP's Most Annoying Error
by derickr on Wednesday September 17, 2014 @04:25AM
(#8329056)
Über-pedantry: It's "you're" and not "your".
Re:How to Fix PHP's Most Annoying Error
by 2upmedia on Wednesday September 17, 2014 @05:08PM
(#8332370)
Unfortunately, HN doesn't have an edit function for comments. ;)
Re:How to Fix PHP's Most Annoying Error
by laumars on Thursday September 18, 2014 @03:29AM
(#8334121)
It does, but only for comments that haven't been replied to
Re:How to Fix PHP's Most Annoying Error
by 2upmedia on Thursday September 18, 2014 @12:14PM
(#8336012)
More pedantry ;)
I was actually trying to be helpful there :(
Re:How to Fix PHP's Most Annoying Error
by 2upmedia on Saturday September 20, 2014 @01:32AM
(#8343765)
Hehe. Based on the previous pendantry, it blended in. I'll take it as help then. :D
Re:How to Fix PHP's Most Annoying Error
by laumars on Tuesday September 23, 2014 @11:04AM
(#8355670)
The previous pedantry wasn't me though; only the MiB / MB comment. And that was partly out of curiosity if 1000MB == 1GB was a deliberate rounding.
Re:How to Fix PHP's Most Annoying Error
by 2upmedia on Tuesday September 16, 2014 @12:19PM
(#8325273)
Increasing the memory limit is only temporary. It's used as a debugging procedure. I later write "If by increasing the memory limit you have gotten rid of the error and your code now works, you’ll need to take measures to decrease that memory usage" with a list of things to do to decrease memory usage.
Re:How to Fix PHP's Most Annoying Error
by martin_ on Tuesday September 16, 2014 @12:22PM
(#8325290)
Sorry I missed that section. Carry on!
Re:How to Fix PHP's Most Annoying Error
by arenaninja on Tuesday September 16, 2014 @12:23PM
(#8325300)
Unless you need the limit to be that high. But I agree that it isn't ideal. However, PHP cleans up nicely once the process ends, and manually freeing memory space can slow PHP down. The only exception I would take to this, I believe, are resources. If is_resource($foo) returns true, you should probably free it (looking at you, JpGraph)