PHP code optimize, Maximum allowed memory error Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow do I get PHP errors to display?403 Forbidden error when getting a page with PHP cURLXML > PHP only in source codeHow to fix “Headers already sent” error in PHPMake a curl request to a url having no file extension?Reference - What does this error mean in PHP?How to load details automaticallycURL not working sometimes and gives empty resultMicrosoft outlook API give 404 errorhow can i check if RESTAPI is down using curl php
Stop battery usage [Ubuntu 18]
Unable to start mainnet node docker container
Mortgage adviser recommends a longer term than necessary combined with overpayments
How do you clear the ApexPages.getMessages() collection in a test?
Choo-choo! Word trains
Statistical model of ligand substitution
Can a monk deflect thrown melee weapons?
How to say 'striped' in Latin
What's the point in a preamp?
Classification of bundles, Postnikov towers, obstruction theory, local coefficients
What do you call the holes in a flute?
How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time
How is simplicity better than precision and clarity in prose?
How to say that you spent the night with someone, you were only sleeping and nothing else?
Did the new image of black hole confirm the general theory of relativity?
How to rotate it perfectly?
Area of a 2D convex hull
Why does tar appear to skip file contents when output file is /dev/null?
Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?
What would be Julian Assange's expected punishment, on the current English criminal law?
Are my PIs rude or am I just being too sensitive?
Is there a service that would inform me whenever a new direct route is scheduled from a given airport?
When is phishing education going too far?
Blender game recording at the wrong time
PHP code optimize, Maximum allowed memory error
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow do I get PHP errors to display?403 Forbidden error when getting a page with PHP cURLXML > PHP only in source codeHow to fix “Headers already sent” error in PHPMake a curl request to a url having no file extension?Reference - What does this error mean in PHP?How to load details automaticallycURL not working sometimes and gives empty resultMicrosoft outlook API give 404 errorhow can i check if RESTAPI is down using curl php
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I try to make my code more reusability. However, I'm not very familiar with PHP. I would like to discuss the code with you guys.
Basically, the post_data
is part of the record_student
. The reason I split it is because I have others similar function to do the curl posting. Therefore, I make a curl function for reuse in others function. The code below will be facing the maximum allow memory
issue. I'm not sure which part goes wrong.
public function record_student()
$url = $this->get_url();
//foreach function to handle the data
$this->post_data();
public function post_data()
$data = $this->sync_sale();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
// Set here requred headers
"Api-key: " . Input::get('api_key'),
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
),
));
$response = curl_exec($curl);
Debugbar::info($response);
php laravel
add a comment |
I try to make my code more reusability. However, I'm not very familiar with PHP. I would like to discuss the code with you guys.
Basically, the post_data
is part of the record_student
. The reason I split it is because I have others similar function to do the curl posting. Therefore, I make a curl function for reuse in others function. The code below will be facing the maximum allow memory
issue. I'm not sure which part goes wrong.
public function record_student()
$url = $this->get_url();
//foreach function to handle the data
$this->post_data();
public function post_data()
$data = $this->sync_sale();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
// Set here requred headers
"Api-key: " . Input::get('api_key'),
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
),
));
$response = curl_exec($curl);
Debugbar::info($response);
php laravel
How many times do you call this method and how large is each$response
on average?
– apokryfos
Mar 22 at 7:58
where is thepost_data()
function obtaining the value of$url
? Either declare$url
as a parameter topost_data
or as aglobal
within
– RamRaider
Mar 22 at 8:00
@apokryfos There have only 12 records so it will be called 12 times. I'm not sure how large the$response
but I only posted name,id and date. It working fine if I didn't split the function to two
– jakie.c
Mar 22 at 8:03
it might be useful to show us the version that works fine and the version that causes a memory issue.
– apokryfos
Mar 22 at 8:06
add a comment |
I try to make my code more reusability. However, I'm not very familiar with PHP. I would like to discuss the code with you guys.
Basically, the post_data
is part of the record_student
. The reason I split it is because I have others similar function to do the curl posting. Therefore, I make a curl function for reuse in others function. The code below will be facing the maximum allow memory
issue. I'm not sure which part goes wrong.
public function record_student()
$url = $this->get_url();
//foreach function to handle the data
$this->post_data();
public function post_data()
$data = $this->sync_sale();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
// Set here requred headers
"Api-key: " . Input::get('api_key'),
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
),
));
$response = curl_exec($curl);
Debugbar::info($response);
php laravel
I try to make my code more reusability. However, I'm not very familiar with PHP. I would like to discuss the code with you guys.
Basically, the post_data
is part of the record_student
. The reason I split it is because I have others similar function to do the curl posting. Therefore, I make a curl function for reuse in others function. The code below will be facing the maximum allow memory
issue. I'm not sure which part goes wrong.
public function record_student()
$url = $this->get_url();
//foreach function to handle the data
$this->post_data();
public function post_data()
$data = $this->sync_sale();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
// Set here requred headers
"Api-key: " . Input::get('api_key'),
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
),
));
$response = curl_exec($curl);
Debugbar::info($response);
php laravel
php laravel
asked Mar 22 at 7:50
jakie.cjakie.c
1
1
How many times do you call this method and how large is each$response
on average?
– apokryfos
Mar 22 at 7:58
where is thepost_data()
function obtaining the value of$url
? Either declare$url
as a parameter topost_data
or as aglobal
within
– RamRaider
Mar 22 at 8:00
@apokryfos There have only 12 records so it will be called 12 times. I'm not sure how large the$response
but I only posted name,id and date. It working fine if I didn't split the function to two
– jakie.c
Mar 22 at 8:03
it might be useful to show us the version that works fine and the version that causes a memory issue.
– apokryfos
Mar 22 at 8:06
add a comment |
How many times do you call this method and how large is each$response
on average?
– apokryfos
Mar 22 at 7:58
where is thepost_data()
function obtaining the value of$url
? Either declare$url
as a parameter topost_data
or as aglobal
within
– RamRaider
Mar 22 at 8:00
@apokryfos There have only 12 records so it will be called 12 times. I'm not sure how large the$response
but I only posted name,id and date. It working fine if I didn't split the function to two
– jakie.c
Mar 22 at 8:03
it might be useful to show us the version that works fine and the version that causes a memory issue.
– apokryfos
Mar 22 at 8:06
How many times do you call this method and how large is each
$response
on average?– apokryfos
Mar 22 at 7:58
How many times do you call this method and how large is each
$response
on average?– apokryfos
Mar 22 at 7:58
where is the
post_data()
function obtaining the value of $url
? Either declare $url
as a parameter to post_data
or as a global
within– RamRaider
Mar 22 at 8:00
where is the
post_data()
function obtaining the value of $url
? Either declare $url
as a parameter to post_data
or as a global
within– RamRaider
Mar 22 at 8:00
@apokryfos There have only 12 records so it will be called 12 times. I'm not sure how large the
$response
but I only posted name,id and date. It working fine if I didn't split the function to two– jakie.c
Mar 22 at 8:03
@apokryfos There have only 12 records so it will be called 12 times. I'm not sure how large the
$response
but I only posted name,id and date. It working fine if I didn't split the function to two– jakie.c
Mar 22 at 8:03
it might be useful to show us the version that works fine and the version that causes a memory issue.
– apokryfos
Mar 22 at 8:06
it might be useful to show us the version that works fine and the version that causes a memory issue.
– apokryfos
Mar 22 at 8:06
add a comment |
2 Answers
2
active
oldest
votes
As per the comment I made I can see no reference to $url
within post_data
other than when it is called ~ unless the code posted above is not the actual code you are running? Provide the url as either a named parameter or declare as a global variable within thge function body or make it a global property of the class by setting $this->url=$this->get_url();
and using $this->url
within the curl function.
I modified the two below methods to reflect the named parameter approach and added some additional debugging code which often provides really useful info for curl requests ~ though I made an assumption that Debugbar::info
can be used to display info to screen/file.
public function record_student()
$url = $this->get_url();
$this->post_data( $url, true ); # call method with named parameters
public function post_data( $url=false, $debug=false )
if( $url )
$data = $this->sync_sale();
if( $data )
$curl = curl_init();
if( $debug ) $vbh = fopen( 'php://temp', 'w+' );
$options=array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"Api-key: " . Input::get('api_key'),
"Accept: */*",
"Accept-Language: en-US,en;q=0.8",
"Content-Type: application/json",
),
);
/* enhanced debugging info if in debug mode */
if( $debug && $vbh )
$options = array_merge( $options, array(
CURLOPT_VERBOSE => true,
CURLOPT_NOPROGRESS => true,
CURLOPT_STDERR => $vbh
));
curl_setopt_array( $curl, $options );
$response = curl_exec( $curl );
curl_close( $curl );
if( $debug && $vbh )
/* process info captured in the temp stream */
rewind( $vbh );
$verbose = stream_get_contents( $vbh );
fclose( $vbh );
/* assumed that Debugbar::info will print data somewhere */
Debugbar::info( $verbose );
Debugbar::info( $response );
return $response;
return false;
add a comment |
Try closing the curl request with curl_close
.
I did but still the same
– jakie.c
Mar 22 at 7:59
what are you doing on sync_sale and get_url? they might be leaking memory
– Adrian Caragea
Mar 22 at 8:02
did you also tryunset($response);
, after the log?
– Adrian Caragea
Mar 22 at 9:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55295058%2fphp-code-optimize-maximum-allowed-memory-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As per the comment I made I can see no reference to $url
within post_data
other than when it is called ~ unless the code posted above is not the actual code you are running? Provide the url as either a named parameter or declare as a global variable within thge function body or make it a global property of the class by setting $this->url=$this->get_url();
and using $this->url
within the curl function.
I modified the two below methods to reflect the named parameter approach and added some additional debugging code which often provides really useful info for curl requests ~ though I made an assumption that Debugbar::info
can be used to display info to screen/file.
public function record_student()
$url = $this->get_url();
$this->post_data( $url, true ); # call method with named parameters
public function post_data( $url=false, $debug=false )
if( $url )
$data = $this->sync_sale();
if( $data )
$curl = curl_init();
if( $debug ) $vbh = fopen( 'php://temp', 'w+' );
$options=array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"Api-key: " . Input::get('api_key'),
"Accept: */*",
"Accept-Language: en-US,en;q=0.8",
"Content-Type: application/json",
),
);
/* enhanced debugging info if in debug mode */
if( $debug && $vbh )
$options = array_merge( $options, array(
CURLOPT_VERBOSE => true,
CURLOPT_NOPROGRESS => true,
CURLOPT_STDERR => $vbh
));
curl_setopt_array( $curl, $options );
$response = curl_exec( $curl );
curl_close( $curl );
if( $debug && $vbh )
/* process info captured in the temp stream */
rewind( $vbh );
$verbose = stream_get_contents( $vbh );
fclose( $vbh );
/* assumed that Debugbar::info will print data somewhere */
Debugbar::info( $verbose );
Debugbar::info( $response );
return $response;
return false;
add a comment |
As per the comment I made I can see no reference to $url
within post_data
other than when it is called ~ unless the code posted above is not the actual code you are running? Provide the url as either a named parameter or declare as a global variable within thge function body or make it a global property of the class by setting $this->url=$this->get_url();
and using $this->url
within the curl function.
I modified the two below methods to reflect the named parameter approach and added some additional debugging code which often provides really useful info for curl requests ~ though I made an assumption that Debugbar::info
can be used to display info to screen/file.
public function record_student()
$url = $this->get_url();
$this->post_data( $url, true ); # call method with named parameters
public function post_data( $url=false, $debug=false )
if( $url )
$data = $this->sync_sale();
if( $data )
$curl = curl_init();
if( $debug ) $vbh = fopen( 'php://temp', 'w+' );
$options=array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"Api-key: " . Input::get('api_key'),
"Accept: */*",
"Accept-Language: en-US,en;q=0.8",
"Content-Type: application/json",
),
);
/* enhanced debugging info if in debug mode */
if( $debug && $vbh )
$options = array_merge( $options, array(
CURLOPT_VERBOSE => true,
CURLOPT_NOPROGRESS => true,
CURLOPT_STDERR => $vbh
));
curl_setopt_array( $curl, $options );
$response = curl_exec( $curl );
curl_close( $curl );
if( $debug && $vbh )
/* process info captured in the temp stream */
rewind( $vbh );
$verbose = stream_get_contents( $vbh );
fclose( $vbh );
/* assumed that Debugbar::info will print data somewhere */
Debugbar::info( $verbose );
Debugbar::info( $response );
return $response;
return false;
add a comment |
As per the comment I made I can see no reference to $url
within post_data
other than when it is called ~ unless the code posted above is not the actual code you are running? Provide the url as either a named parameter or declare as a global variable within thge function body or make it a global property of the class by setting $this->url=$this->get_url();
and using $this->url
within the curl function.
I modified the two below methods to reflect the named parameter approach and added some additional debugging code which often provides really useful info for curl requests ~ though I made an assumption that Debugbar::info
can be used to display info to screen/file.
public function record_student()
$url = $this->get_url();
$this->post_data( $url, true ); # call method with named parameters
public function post_data( $url=false, $debug=false )
if( $url )
$data = $this->sync_sale();
if( $data )
$curl = curl_init();
if( $debug ) $vbh = fopen( 'php://temp', 'w+' );
$options=array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"Api-key: " . Input::get('api_key'),
"Accept: */*",
"Accept-Language: en-US,en;q=0.8",
"Content-Type: application/json",
),
);
/* enhanced debugging info if in debug mode */
if( $debug && $vbh )
$options = array_merge( $options, array(
CURLOPT_VERBOSE => true,
CURLOPT_NOPROGRESS => true,
CURLOPT_STDERR => $vbh
));
curl_setopt_array( $curl, $options );
$response = curl_exec( $curl );
curl_close( $curl );
if( $debug && $vbh )
/* process info captured in the temp stream */
rewind( $vbh );
$verbose = stream_get_contents( $vbh );
fclose( $vbh );
/* assumed that Debugbar::info will print data somewhere */
Debugbar::info( $verbose );
Debugbar::info( $response );
return $response;
return false;
As per the comment I made I can see no reference to $url
within post_data
other than when it is called ~ unless the code posted above is not the actual code you are running? Provide the url as either a named parameter or declare as a global variable within thge function body or make it a global property of the class by setting $this->url=$this->get_url();
and using $this->url
within the curl function.
I modified the two below methods to reflect the named parameter approach and added some additional debugging code which often provides really useful info for curl requests ~ though I made an assumption that Debugbar::info
can be used to display info to screen/file.
public function record_student()
$url = $this->get_url();
$this->post_data( $url, true ); # call method with named parameters
public function post_data( $url=false, $debug=false )
if( $url )
$data = $this->sync_sale();
if( $data )
$curl = curl_init();
if( $debug ) $vbh = fopen( 'php://temp', 'w+' );
$options=array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"Api-key: " . Input::get('api_key'),
"Accept: */*",
"Accept-Language: en-US,en;q=0.8",
"Content-Type: application/json",
),
);
/* enhanced debugging info if in debug mode */
if( $debug && $vbh )
$options = array_merge( $options, array(
CURLOPT_VERBOSE => true,
CURLOPT_NOPROGRESS => true,
CURLOPT_STDERR => $vbh
));
curl_setopt_array( $curl, $options );
$response = curl_exec( $curl );
curl_close( $curl );
if( $debug && $vbh )
/* process info captured in the temp stream */
rewind( $vbh );
$verbose = stream_get_contents( $vbh );
fclose( $vbh );
/* assumed that Debugbar::info will print data somewhere */
Debugbar::info( $verbose );
Debugbar::info( $response );
return $response;
return false;
answered Mar 22 at 8:22
RamRaiderRamRaider
18.7k31935
18.7k31935
add a comment |
add a comment |
Try closing the curl request with curl_close
.
I did but still the same
– jakie.c
Mar 22 at 7:59
what are you doing on sync_sale and get_url? they might be leaking memory
– Adrian Caragea
Mar 22 at 8:02
did you also tryunset($response);
, after the log?
– Adrian Caragea
Mar 22 at 9:35
add a comment |
Try closing the curl request with curl_close
.
I did but still the same
– jakie.c
Mar 22 at 7:59
what are you doing on sync_sale and get_url? they might be leaking memory
– Adrian Caragea
Mar 22 at 8:02
did you also tryunset($response);
, after the log?
– Adrian Caragea
Mar 22 at 9:35
add a comment |
Try closing the curl request with curl_close
.
Try closing the curl request with curl_close
.
edited Mar 22 at 8:22
double-beep
3,13641532
3,13641532
answered Mar 22 at 7:55
Adrian CarageaAdrian Caragea
1098
1098
I did but still the same
– jakie.c
Mar 22 at 7:59
what are you doing on sync_sale and get_url? they might be leaking memory
– Adrian Caragea
Mar 22 at 8:02
did you also tryunset($response);
, after the log?
– Adrian Caragea
Mar 22 at 9:35
add a comment |
I did but still the same
– jakie.c
Mar 22 at 7:59
what are you doing on sync_sale and get_url? they might be leaking memory
– Adrian Caragea
Mar 22 at 8:02
did you also tryunset($response);
, after the log?
– Adrian Caragea
Mar 22 at 9:35
I did but still the same
– jakie.c
Mar 22 at 7:59
I did but still the same
– jakie.c
Mar 22 at 7:59
what are you doing on sync_sale and get_url? they might be leaking memory
– Adrian Caragea
Mar 22 at 8:02
what are you doing on sync_sale and get_url? they might be leaking memory
– Adrian Caragea
Mar 22 at 8:02
did you also try
unset($response);
, after the log?– Adrian Caragea
Mar 22 at 9:35
did you also try
unset($response);
, after the log?– Adrian Caragea
Mar 22 at 9:35
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55295058%2fphp-code-optimize-maximum-allowed-memory-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How many times do you call this method and how large is each
$response
on average?– apokryfos
Mar 22 at 7:58
where is the
post_data()
function obtaining the value of$url
? Either declare$url
as a parameter topost_data
or as aglobal
within– RamRaider
Mar 22 at 8:00
@apokryfos There have only 12 records so it will be called 12 times. I'm not sure how large the
$response
but I only posted name,id and date. It working fine if I didn't split the function to two– jakie.c
Mar 22 at 8:03
it might be useful to show us the version that works fine and the version that causes a memory issue.
– apokryfos
Mar 22 at 8:06