Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6556331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:55:53+00:00 2026-05-25T12:55:53+00:00

I have a script that is running on a shared hosting environment where I

  • 0

I have a script that is running on a shared hosting environment where I can’t change the available amount of PHP memory. The script is consuming a web service via soap. I can’t get all my data at once or else it runs out of memory so I have had some success with caching the data locally in a mysql database so that subsequent queries are faster.

Basically instead of querying the web service for 5 months of data I am querying it 1 month at a time and storing that in the mysql table and retrieving the next month etc. This usually works but I sometimes still run out of memory.

my basic code logic is like this:

  1. connect to web service using soap;
  2. connect to mysql database
  3. query web service and store result in variable $results;
  4. dump $results into mysql table
  5. repeat steps 3 and 4 for each month of data

the same variables are used in each iteration so I would assume that each batch of results from the web service would overwrite the previous in memory? I tried using unset($results) in between iterations but that didn’t do anything. I am outputting the memory used with memory_get_usage(true) each time and with every iteration the memory used is increased.

Any ideas how I can fix this memory leak? If I wasn’t clear enough leave a comment and I can provide more details. Thanks!

***EDIT

Here is some code (I am using nusoap not the php5 native soap client if that makes a difference):

$startingDate = strtotime("3/1/2011");
$endingDate = strtotime("7/31/2011");
// connect to database
mysql_connect("dbhost.com", "dbusername" "dbpassword");
mysql_select_db("dbname");
// configure nusoap
$serverpath ='http://path.to/wsdl';
$client = new nusoap_client($serverpath);
// cache soap results locally
while($startingDate<=$endingDate) {
    $sql = "SELECT * FROM table WHERE date >= ".date('Y-m-d', $startingDate)." AND date <= ".date('Y-m-d', strtotime($startingDate.' +1 month'));
    $soapResult = $client->call('SelectData', $sql);
    foreach($soapResult['SelectDateResult']['Result']['Row'] as $row) {
        foreach($row as &$data) {
            $data = mysql_real_escape_string($data);
        }
        $sql = "INSERT INTO table VALUES('".$row['dataOne']."', '".$row['dataTwo']."', '".$row['dataThree'].")";
        $mysqlResults = mysql_query($sql);
    }
    $startingDate = strtotime($startingDate." +1 month");
    echo memory_get_usage(true); // MEMORY INCREASES EACH ITERATION
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:55:54+00:00Added an answer on May 25, 2026 at 12:55 pm

    Solved it. At least partially. There is a memory leak using nusoap. Nusoap writes a debug log to a $GLOBALS variable. Altering this line in nusoap.php freed up a lot of memory.

    change

    $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel = 9;
    

    to

    $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel = 0;
    

    I’d prefer to just use php5’s native soap client but I’m getting strange results that I believe are specific to the webservice I am trying to consume. If anyone is familiar with using php5’s soap client with http://www.mindbodyonline.com ‘s SOAP API let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script that is running in CLI and I want to
I have a PHP script (running on a Linux server) that ouputs the names
I have a PHP script running on XAMPP in Windows XP that will open
I have a Python script that is running a few ls commands. This script
I have a script that I'm running from the home directory to search for
I have a python script that ends with running a program (iexpress.exe) in a
Problem: I have a python script that I have running as a service. It's
I have a script that is supposed to sit there, happily running in a
I have an IronPython script that looks for current running processes using WMI. The
I have a Perl/POE/Tk script running on Win32 ActivePerl that calls executables using system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.