Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
693 views
in Technique[技术] by (71.8m points)

php - Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)

I was going crazy with this.

I got the next message:

Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)

TODO LIST

Check phpinfo(), got the right php.ini route and edit it. Change memory_limit to

memory_limit = 128M

Make sure the value memory_limit changes con phpinfo() with the result:

memory_limit    128MB   128MB

Check .htaccess and added (not needed)

php_value memory_limit 128M

And also to change it via php like so (before error line):

ini_set('memory_limit','128M');

It says everywhere that memory is set to 128M, but still get that error?

The error is in Swift library (library for sending emails), in abstractSmtpTransport.php, so it's not my code int's suposed to work.

Any ideas???

Edit: Yes, the previous was done restarting apache.

EDIT 2: @patrick, added that but nothing was echoed

Tryed with lower value, 28M int every file, restarted apache, same error (phpinfo showed new value)

tried with -1, restarting, and same error.

EDIT 3: isn't it weird that allowed memory is bigger than allocated memory? (despite the fact that allowed memory size is way below real allowed memory asigned)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I see my problem is a little bit different from yours, but I'll post this answer in case it helps someone else. I was using MB as shorthand instead of M when defining my memory_limit, and php was silently ignoring it. I changed it to an integer (in bytes) and the problem was solved.

My php.ini changed as follows: memory_limit = 512MB to memory_limit = 536870912. This fixed my problem. Hope it helps with someone else's! You can read up on php's shorthand here.

Good luck!

Edit

As Yaodong points out, you can just as easily use the correct shorthand, "M", instead of using byte values. I changed mine to byte values for debugging purposes and then didn't bother to change it back.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...