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-12 12:08:17
Point:500 Replies:5 POST_ID:828504USER_ID:11059
Topic:
Linux;;PHP Scripting Language
I run following curl php script to grab 36meg data from remote server site and save it
into one varaible like $htm and $file_url. And the error report: Out of memory in my_curl function
at $htm=curl_exec($url)
Is it not allowed I put the data at such big size into one variable ?
If not, how can I put 32M data into one variable, i know there is something related
to curl and memory reallocation. Any one has that code, please advise for me for a start
I have checked phpinfo() my php max memory limit is 128Meg and also
add php_value memor_limit 120M in my .htaccess file
into one varaible like $htm and $file_url. And the error report: Out of memory in my_curl function
at $htm=curl_exec($url)
Is it not allowed I put the data at such big size into one variable ?
If not, how can I put 32M data into one variable, i know there is something related
to curl and memory reallocation. Any one has that code, please advise for me for a start
I have checked phpinfo() my php max memory limit is 128Meg and also
add php_value memor_limit 120M in my .htaccess file
<?php$file_url=my_curl("wwww.example.com","" , 3000, TRUE);function my_curl( $url, $get_array=array(), $timeout=3, $error_report=TRUE){ // PREPARE THE ARGUMENT STRING IF NEEDED // $get_string = ''; // foreach ($get_array as $key => $val) // { // $get_string // = $get_string // . urlencode($key) // . '=' // . urlencode($val) // . '&'; // } // $get_string = rtrim($get_string, '&'); if (!empty($get_string)) $url .= '?' . $get_string; $curl = curl_init(); // HEADERS AND OPTIONS APPEAR TO BE A FIREFOX BROWSER REFERRED BY GOOGLE $header[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; $header[] = "Pragma: "; // BROWSERS USUALLY LEAVE BLANK // SET THE CURL OPTIONS - SEE http://php.net/manual/en/function.curl-setopt.php curl_setopt( $curl, CURLOPT_URL, $url ); curl_setopt( $curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6' ); curl_setopt( $curl, CURLOPT_HTTPHEADER, $header ); curl_setopt( $curl, CURLOPT_REFERER, 'http://www.google.com' ); curl_setopt( $curl, CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $curl, CURLOPT_AUTOREFERER, TRUE ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); // curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE ); curl_setopt( $curl, CURLOPT_TIMEOUT, $timeout ); // RUN THE CURL REQUEST AND GET THE RESULTS $htm = curl_exec($curl); // ON FAILURE HANDLE ERROR MESSAGE //global $track; // declaring global variable if ($htm === FALSE) { if ($error_report) { $err = curl_errno($curl); $inf = curl_getinfo($curl); // echo "FAILC: $url TIMEOUT=$timeout, CURL_ERRNOC=$err"; var_dump($inf); } curl_close($curl); return FALSE; } // ON SUCCESS RETURN XML / HTML STRING curl_close($curl); return $htm;}?> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:
configurationPHP CoreDirective =>" Local Value =>" Master Valueallow_call_time_pass_reference =>" On =>" Onallow_url_fopen =>" On =>" Onallow_url_include =>" Off =>" Offalways_populate_raw_post_data =>" Off =>" Offarg_separator.input =>" &" =>" &"arg_separator.output =>" &" =>" &"asp_tags =>" Off =>" Offauto_append_file =>" no value =>" no valueauto_globals_jit =>" On =>" Onauto_prepend_file =>" /usr/lib/php/head.php =>" /usr/lib/php/head.phpbrowscap =>" no value =>" no valuedefault_charset =>" no value =>" no valuedefault_mimetype =>" text/html =>" text/htmldefine_syslog_variables =>" Off =>" Offdetect_unicode =>" On =>" Ondisable_classes =>" no value =>" no valuedisable_functions =>" symlink,shell_exec,exec,proc_close,proc_open,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source =>" symlink,shell_exec,exec,proc_close,proc_open,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_sourcedisplay_errors =>" STDOUT =>" STDOUTdisplay_startup_errors =>" Off =>" Offdoc_root =>" no value =>" no valuedocref_ext =>" no value =>" no valuedocref_root =>" no value =>" no valueenable_dl =>" Off =>" Offerror_append_string =>" no value =>" no valueerror_log =>" error_log =>" error_logerror_prepend_string =>" no value =>" no valueerror_reporting =>" 6135 =>" 6135expose_php =>" On =>" Onextension_dir =>" /usr/local/lib/php/extensions/no-debug-non-zts-20060613 =>" /usr/local/lib/php/extensions/no-debug-non-zts-20060613file_uploads =>" On =>" Onhighlight.bg =>" <"font style="color: #FFFFFF">"#FFFFFF<"/font>" =>" <"font style="color: #FFFFFF">"#FFFFFF<"/font>"highlight.comment =>" <"font style="color: #FF8000">"#FF8000<"/font>" =>" <"font style="color: #FF8000">"#FF8000<"/font>"highlight.default =>" <"font style="color: #0000BB">"#0000BB<"/font>" =>" <"font style="color: #0000BB">"#0000BB<"/font>"highlight.html =>" <"font style="color: #000000">"#000000<"/font>" =>" <"font style="color: #000000">"#000000<"/font>"highlight.keyword =>" <"font style="color: #007700">"#007700<"/font>" =>" <"font style="color: #007700">"#007700<"/font>"highlight.string =>" <"font style="color: #DD0000">"#DD0000<"/font>" =>" <"font style="color: #DD0000">"#DD0000<"/font>"html_errors =>" Off =>" Offignore_repeated_errors =>" On =>" Onignore_repeated_source =>" On =>" Onignore_user_abort =>" Off =>" Offimplicit_flush =>" On =>" Oninclude_path =>" .:/usr/lib/php:/usr/local/lib/php =>" .:/usr/lib/php:/usr/local/lib/phplog_errors =>" On =>" Onlog_errors_max_len =>" 1024 =>" 1024magic_quotes_gpc =>" On =>" Onmagic_quotes_runtime =>" Off =>" Offmagic_quotes_sybase =>" Off =>" Offmail.force_extra_parameters =>" no value =>" no valuemax_execution_time =>" 0 =>" 0max_file_uploads =>" 20 =>" 20max_input_nesting_level =>" 64 =>" 64max_input_time =>" -1 =>" -1memory_limit =>" 128M =>" 128Mopen_basedir =>" no value =>" no valueoutput_buffering =>" 0 =>" 0output_handler =>" no value =>" no valuepost_max_size =>" 128M =>" 128Mprecision =>" 12 =>" 12realpath_cache_size =>" 16K =>" 16Krealpath_cache_ttl =>" 120 =>" 120register_argc_argv =>" On =>" Onregister_globals =>" Off =>" Offregister_long_arrays =>" On =>" Onreport_memleaks =>" On =>" Onreport_zend_debug =>" Off =>" Offsafe_mode =>" Off =>" Offsafe_mode_exec_dir =>" /usr/local/php/bin =>" /usr/local/php/binsafe_mode_gid =>" Off =>" Offsafe_mode_include_dir =>" no value =>" no valuesendmail_from =>" no value =>" no valuesendmail_path =>" /usr/sbin/sendmail -t -i =>" /usr/sbin/sendmail -t -iserialize_precision =>" 100 =>" 100short_open_tag =>" On =>" OnSMTP =>" localhost =>" localhostsmtp_port =>" 25 =>" 25sql.safe_mode =>" Off =>" Offtrack_errors =>" Off =>" Offunserialize_callback_func =>" no value =>" no valueupload_max_filesize =>" 128M =>" 128Mupload_tmp_dir =>" /tmp =>" /tmpuser_dir =>" no value =>" no valuevariables_order =>" EGPCS =>" EGPCSxmlrpc_error_number =>" 0 =>" 0xmlrpc_errors =>" Off =>" Offy2k_compliance =>" On =>" Onzend.ze1_compatibility_mode =>" Off =>" Off 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:74:75:76:77:78:79:80:81:82:83:84:85:86:87:88:89:90:91:
my .htaccess file# -FrontPage-<"Limit GET POST>"order deny,allowdeny from allallow from all<"/Limit>"<"Limit PUT DELETE>"order deny,allowdeny from all<"/Limit>"php_value memory_limit 120MAuthUserFile /home/aab/public_html/_vti_pvt/service.pwdAuthGroupFile /home/aab/public_html/_vti_pvt/service.grpAuthName aaa.comIndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:
Author: duncanb7 replied at 2024-05-17 06:27:56
For my memo:
We need to do
sprintf(%.3f, $var) that will
save or reduce variable size , and now it is passed the out of memory
error
If the file size is too big, and then
php script do data calculation
for each data , and if the data is without truncation like 123.123456789012333333333322222222222222222222222 which
will create the file size is bigger and bigger once we save the file after
calculation. So it might use up all memory
We need to do
sprintf(%.3f, $var) that will
save or reduce variable size , and now it is passed the out of memory
error
If the file size is too big, and then
php script do data calculation
for each data , and if the data is without truncation like 123.123456789012333333333322222222222222222222222 which
will create the file size is bigger and bigger once we save the file after
calculation. So it might use up all memory
Author: duncanb7 replied at 2024-05-17 04:08:58
I already curl it into file succesfully , now it has new other error message about out of memory when I open (using fopen or using file() ) i t and store into $csv about 2.5meg which is not allowed even I already set
max_limit=128Meg.
Why ? please advise
max_limit=128Meg.
Why ? please advise
Author: duncanb7 replied at 2024-05-17 04:07:41
I already curl it into file succesfully , now it is still error message about out of memory.
but when I open (using fopen or using file() ) i t and store into $htm about 2.5meg which is not allowed even I already set
max_limit=128.
Why ? please advise
but when I open (using fopen or using file() ) i t and store into $htm about 2.5meg which is not allowed even I already set
max_limit=128.
Why ? please advise
Assisted Solution
Expert: Zyloch replied at 2024-05-14 03:25:12
250 points GOOD
By the way, what is the exact error message you get? It may indicate how much memory you are trying to allocate out of how much is available.
Accepted Solution
Expert: Zyloch replied at 2024-05-14 03:24:17
250 points GOOD
I agree that this is strange. One thing to make sure is that you have restarted your server after the changes to memory_limit in your php.ini file. If you do not own the server, make sure that you are allowed to raise your memory limit.
One way to bypass the need for cURL to store the entire file into a variable in memory is to have it write to a file. You can find out how to do that via this tutorial.
One way to bypass the need for cURL to store the entire file into a variable in memory is to have it write to a file. You can find out how to do that via this tutorial.