PHP MEMORY_LIMIT

For bad reasons I need to mix memory_limits higher than 1 GB for a directory, but on my PHP 5.2.17 on a Debian 5.0 (Lenny) VPS when I use, for example, 2048M, I get only the php.ini default value (256M).

Bạn đang xem: Php memory_limit

PHP runs as an Apabịt module, & phpinfo gives us (for the directory):

memory_limit 1024M 256Msuhosin.memory_limit 0 0Is there a limitation due lớn an Apache module, or the PHP configuration? I know the VPS only has 4 GB of RAM. It"s just a special script.


*

*

How are you trying lớn phối the memory limit? phpinfo() shows current PHPhường reserved memory limit, và this is what is available due to lớn php.ini having that phối as a memory limit.

Writing this lớn the Apabít .htaccess file in your script directory might work if your hệ thống supports setting PHP commands through .htaccess:

php_value memory_limit 2048MSince it may be possible that .htaccess commands for setting PHPhường. values are turned off. Then you can also try this from PHPhường code:

ini_set("memory_limit", "2048M");If this doesn"t work & .htaccess also doesn"t work, then you need lớn tương tác the VPS administrators.


*

*

I had this same issue where I needed my PHP. script khổng lồ use 4 GBs of RAM. The reason doesn"t matter. The goal was to lớn phối a 4 GB limit in PHP.

The initial idea was to lớn use ini_set("memory_limit", "4096M");, but I found that this didn"t work. I have sầu no idea how or why lớn be honest, but that wasn"t important khổng lồ me at the time. I"m on a system with 32 GBs of RAM, & it has lớn be possible.

I found that setting a limit 1 MB less actually worked, & it"s a solution that worked for me.

ini_set("memory_limit", "4095M"); // 4 GBs minus 1 MBActually, I"ve sầu never really played with it before, but I"ve noticed on my system that this value seems to completely remove all memory limits for me. I"m able to use as much RAM as my system possibly provides.

Xem thêm: Club Tình Một Đêm - Câu Lạc Bộ Tình Một Đêm


*

As described in Hardened-PHP - Configuration, Suhosin will not let you set a value greater than the one the script started with.

If you mix the suhosin.memory_limit to 2048M then you"ll be able khổng lồ increase your memory usage.


The limit of

ini_set("memory_limit", "4095M"); // 4 GBs minus 1 MBis related khổng lồ the operating system (OS). With a 32-bit OS you must use this maximum limit.

I resolved an issue with memory_limit today using this workaround.

Using a higher limit, PHPhường has strange behaviour. It returns exhausted memory in some public non-static method class when a class was instanced, but putting a die() in the __construct method (khổng lồ thử nghiệm the problem).


Thanks for contributing an answer khổng lồ Stachồng Overflow!

Please be sure to answer the question. Provide details & giới thiệu your research!

But avoid

Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; baông chồng them up with references or personal experience.

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree khổng lồ our terms of service, privacy policy và cookie policy


Not the answer you're looking for? Browse other questions tagged php memory-limit or ask your own question.


How can I stop an infinite recursive function in PHP from eating all the available memory and eventually crashing the laptop?
I have changed every last PHP..ini, *.ini related or unrelated on my hệ thống for setting post_max_size khổng lồ 8000M but its not working
site design / hình ảnh sản phẩm © 2021 Stachồng Exchange Inc; user contributions licensed under cc by-sa. rev2021.12.22.41046


Your privacy

By clicking “Accept all cookies”, you agree Stachồng Exchange can store cookies on your device & discthua information in accordance with our Cookie Policy.