Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-05-21 01:50:19
Point:500 Replies:28 POST_ID:828509USER_ID:11059
Topic:
PHP Scripting Language;;Linux
System already set memory_limit=128M in php.ini and .htaccess
and we conclude the setting in php.ini and .htacess for Aapache only and not work for command line
we could not find out where the other php.ini is for command line and start a test to solve the issue as follow
and myprogram.php script requires only 42Meg to complete
Testing:
================
Test-1
php -f myprogram.php
Fatal Error: out of memory (allocated 8,388,608)(tried to allocated 71 byte) in /home/mydomain/public_html/myprogram.php
Test-2
php -n -d memory_limt=128Meg -f myprogram.php / /where -n "No php.ini file can be used"
Fatal Error: out of memory (allocated 27,262,000)(tried to allocated 71 byte) in /home/mydomain/public_html/myprogrm.php
Test-3
php -n d memory_limited=1Meg -f myprogram.php //for tesitng 1Meg setting
Fatal Error: Allowed memory size of 1Meg is exahusted
You can see only Test-3 is related to memory limit issue if you read the error message in which you can find the word of "exhausted"
In test-1 and test-2, they might not be related to memory_limit, it might be caused by other setting in ulimit -a command setting
Please advise why even we use -n option but we can NOT allocated more than 27.3Meg memory with memory_limit=128M set at command line ?
Duncan
and we conclude the setting in php.ini and .htacess for Aapache only and not work for command line
we could not find out where the other php.ini is for command line and start a test to solve the issue as follow
and myprogram.php script requires only 42Meg to complete
Testing:
================
Test-1
php -f myprogram.php
Fatal Error: out of memory (allocated 8,388,608)(tried to allocated 71 byte) in /home/mydomain/public_html/myprogram.php
Test-2
php -n -d memory_limt=128Meg -f myprogram.php / /where -n "No php.ini file can be used"
Fatal Error: out of memory (allocated 27,262,000)(tried to allocated 71 byte) in /home/mydomain/public_html/myprogrm.php
Test-3
php -n d memory_limited=1Meg -f myprogram.php //for tesitng 1Meg setting
Fatal Error: Allowed memory size of 1Meg is exahusted
You can see only Test-3 is related to memory limit issue if you read the error message in which you can find the word of "exhausted"
In test-1 and test-2, they might not be related to memory_limit, it might be caused by other setting in ulimit -a command setting
Please advise why even we use -n option but we can NOT allocated more than 27.3Meg memory with memory_limit=128M set at command line ?
Duncan
myprogram.php==========================<?php//ini_set('memory_limit', '128M');for ($c=0 ;$c<50000;++$c) {$linerow[$c]="aaaaaaaaaaaaaaaaaaaaaaaaaa";}echo "memory usage=".memory_get_usage(). "";?> 1:2:3:4:5:6:7:8:9:10:
Author: duncanb7 replied at 2024-05-21 04:47:47
can use it on SSH but memory control by host , I can run it on IE
or by Lynx
Anyway, thanks a lot
or by Lynx
Anyway, thanks a lot
Expert: rubene replied at 2024-05-21 04:45:59
Ah that's strange, because in the end doesn't the cron-job run from the shell too and also under the same user as you use on the ssh shell?
Also this is just my personal workstation, so it's not a hosted environment.
Also this is just my personal workstation, so it's not a hosted environment.
Author: duncanb7 replied at 2024-05-21 04:37:13
they replied Doing cron-job in Cpanel for php script is no problem but not allowed for SSH shell
Author: duncanb7 replied at 2024-05-21 04:35:45
Is it your server VPS or share-server ? Which host company are you using ?
I want to collect your ulimit -a output to report to my host company for comparsion
I want to collect your ulimit -a output to report to my host company for comparsion
Expert: rubene replied at 2024-05-21 04:17:56
Actually it's in kilobytes, so yes 32K.
Author: duncanb7 replied at 2024-05-21 04:16:44
my max locked memory is limited to 32M, that is 32K ? or 32M?
Expert: rubene replied at 2024-05-21 04:16:41
Ah sucks, sorry to hear about that, was hoping we could actually fix this.
Expert: rubene replied at 2024-05-21 04:15:57
Yep, seems like the same situation as yours. Can they raise the cpanel shell limitation?
Author: duncanb7 replied at 2024-05-21 04:14:48
Thanks for your reply and at
least finally get the answer even
it can not be solved.
Host says they don't change ulimit
setting for me for security reason
least finally get the answer even
it can not be solved.
Host says they don't change ulimit
setting for me for security reason
Author: duncanb7 replied at 2024-05-21 04:12:57
Accepted Solution
Expert: rubene replied at 2024-05-21 04:04:05
500 points EXCELLENT
Yeah what he says seems about right, because if you look at your ulimit output it says your max locked memory is limited to 32M.
My ulimit shows everything's unlimited:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 266
virtual memory (kbytes, -v) unlimited
My ulimit shows everything's unlimited:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 266
virtual memory (kbytes, -v) unlimited
Author: duncanb7 replied at 2024-05-21 03:58:26
Finally get the reply from host provider .
Hello Duncan,
It seems that the reason of the error occurs is not because of the PHP memory_limit usage of your script, but it is because the shell limitation. With cPanel shell, the problem could caused by the forkbomb setting of your cPanel limited the PHP memory.
Should you need more information, please don't hesitate to contact us.
Many Thanks,
Lewis M.
Sales Manager
Hello Duncan,
It seems that the reason of the error occurs is not because of the PHP memory_limit usage of your script, but it is because the shell limitation. With cPanel shell, the problem could caused by the forkbomb setting of your cPanel limited the PHP memory.
Should you need more information, please don't hesitate to contact us.
Many Thanks,
Lewis M.
Sales Manager
Author: duncanb7 replied at 2024-05-21 03:50:39
Dear rubene,
Coud you send me your ulimit -a output to me to compare it
Coud you send me your ulimit -a output to me to compare it
Author: duncanb7 replied at 2024-05-21 03:49:58
This my ulmit output, is there any problem so I get out of memory error for php script, please advise, anyone ?
=================================================================================
core file size (blocks, -c) 200000
data seg size (kbytes, -d) 200000
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 73728
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) 200000
open files (-n) 100
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 20
virtual memory (kbytes, -v) 200000
file locks (-x) unlimited Accept and Award Points Accept as Solution
=================================================================================
core file size (blocks, -c) 200000
data seg size (kbytes, -d) 200000
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 73728
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) 200000
open files (-n) 100
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 20
virtual memory (kbytes, -v) 200000
file locks (-x) unlimited Accept and Award Points Accept as Solution
Author: duncanb7 replied at 2024-05-21 03:30:26
They said it is 128Meg for php memory_limit and user can change any option in /usr/local/lib/php.ini
and also run it in my IE /FF broswer, it works and report out the memory usage=42M too in browsers.
But I don't know why it doesn't work at commnad line
and also run it in my IE /FF broswer, it works and report out the memory usage=42M too in browsers.
But I don't know why it doesn't work at commnad line
Expert: rubene replied at 2024-05-21 03:04:54
Ah okay, if I run that I get:
Bender:~ ruben$ php -f test.php
memory usage=39526568
So approximately 39 mb.
I'm thinking that your hostingprovider capped the memory_limit. Possibly at 32mb. I think you should contact them to ask if it could be raised.
Bender:~ ruben$ php -f test.php
memory usage=39526568
So approximately 39 mb.
I'm thinking that your hostingprovider capped the memory_limit. Possibly at 32mb. I think you should contact them to ask if it could be raised.
Author: duncanb7 replied at 2024-05-21 02:53:48
myprogram.php
==========================
<?php
ini_set('memory_limit', '128M');
for ($c=0 ;$c<200000;++$c) {
$linerow[$c]="aaaaaaaaaaaaaaaaaaaaaaaaaa";
}
echo "memory usage=".memory_get_usage(). "";
?>
==========================
<?php
ini_set('memory_limit', '128M');
for ($c=0 ;$c<200000;++$c) {
$linerow[$c]="aaaaaaaaaaaaaaaaaaaaaaaaaa";
}
echo "memory usage=".memory_get_usage(). "";
?>
Author: duncanb7 replied at 2024-05-21 02:52:49
Sorry it is not 50,000, and it is 4 times of 50000 , $c=200,000
Could you try it at your side again
Could you try it at your side again
Author: duncanb7 replied at 2024-05-21 02:50:32
Yes my server is share-server by my host provider
Expert: rubene replied at 2024-05-21 02:48:25
"If it works, why I go to switch to use
option -n, -c
-n "No php.ini file can be used"
-c "include php.in file "
"
I don't know what you mean by that. I just said that ini_get('memory_limit') works just fine from cli too. It's not restricted to a web environment.
If I execute this script:
option -n, -c
-n "No php.ini file can be used"
-c "include php.in file "
"
I don't know what you mean by that. I just said that ini_get('memory_limit') works just fine from cli too. It's not restricted to a web environment.
If I execute this script:
<?phpini_set('memory_limit', '256M');echo ini_get('memory_limit');for ($c=0 ;$c<50000;++$c) {$linerow[$c]="aaaaaaaaaaaaaaaaaaaaaaaaaa";}echo "memory usage=".memory_get_usage(). ""; 1:2:3:4:5:6:7:8:
php -f test.php
256Mmemory usage=10353720
And if I execute it without specifically setting the memory_limit:
<?phpecho ini_get('memory_limit');for ($c=0 ;$c<50000;++$c) {$linerow[$c]="aaaaaaaaaaaaaaaaaaaaaaaaaa";}echo "memory usage=".memory_get_usage(). ""; 1:2:3:4:5:6:7:
I get this:
php -f test.php
128Mmemory usage=10352968
So it never exceeds 10 mb of memory usage.
It seems like your settings are capped somewhere. Are you on a shared hosting environment?
Author: duncanb7 replied at 2024-05-21 02:37:31
it seems it is related to memory_limit because when I set
memory_limit, it report 8.3M allocated and if set memory_limit=1M
it report Allowed memory of 1M is exhausted. SO you can memory_limit
is reacting but can not let php allocate more memory than 42.M(my script requirement) or 128M
Is there for loop issue in my php script , too long of $c variable for ($c=0 ;$c<50000;++$c) {}
The pointer is too long to cause system error
memory_limit, it report 8.3M allocated and if set memory_limit=1M
it report Allowed memory of 1M is exhausted. SO you can memory_limit
is reacting but can not let php allocate more memory than 42.M(my script requirement) or 128M
Is there for loop issue in my php script , too long of $c variable for ($c=0 ;$c<50000;++$c) {}
The pointer is too long to cause system error
Author: duncanb7 replied at 2024-05-21 02:34:03
If it works, why I go to switch to use
option -n, -c
-n "No php.ini file can be used"
-c "include php.in file "
option -n, -c
-n "No php.ini file can be used"
-c "include php.in file "
Author: duncanb7 replied at 2024-05-21 02:32:16
I try it before many times, it get the same result as test-1
Expert: rubene replied at 2024-05-21 02:28:22
ini_get('memory_limit') works from cli too, no problem.
Can you try it, cause I'm curious about the output.
Also make sure the user has read rights on the php.ini you're trying to use.
Can you try it, cause I'm curious about the output.
Also make sure the user has read rights on the php.ini you're trying to use.
Author: duncanb7 replied at 2024-05-21 02:17:04
I try to copy system php.ini into my public_html directory and
try
php -c ./php.ini -f myprogram.php that get the same fatal error message
if editing and change memory_limit to 128M in my php.in at public_html , same error as test_1
if memory_limit=1M,same error as test-3
So it seems it realted to other setting for memory resource , How can use ulimit -a and set setting ?
try
php -c ./php.ini -f myprogram.php that get the same fatal error message
if editing and change memory_limit to 128M in my php.in at public_html , same error as test_1
if memory_limit=1M,same error as test-3
So it seems it realted to other setting for memory resource , How can use ulimit -a and set setting ?
Author: duncanb7 replied at 2024-05-21 02:14:11
init_get("memory_limit") is no use for command line, it won't read it,
That init_get() is for Apache only or running in IE/FF broswer only
That init_get() is for Apache only or running in IE/FF broswer only
Expert: rubene replied at 2024-05-21 01:57:59
Also, what does this return:
<?php
ini_get('memory_limit');
?>
<?php
ini_get('memory_limit');
?>
Expert: rubene replied at 2024-05-21 01:56:33
Have you tried using the -c commandline switch to point specifically to the php.ini you want to use?