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 9217579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:39:51+00:00 2026-06-18T02:39:51+00:00

I have a script with using a lot of Magic method __call. The script

  • 0

I have a script with using a lot of Magic method __call.
The script have 15 000 iterance and the object is bigger.
After every iterance the memory grows. I use unset or $val = null; but the memory continues to grow.

What can i do?

An Exemple :

$data = null;
foreach ($field['method']['actions'] as $action) {
    // si l'action ne concerne pas le name space principal
    if (!array_key_exists('get', $action)) {
        continue;
    }
    if (array_key_exists('begin', $action)) {
        $data .= $action['begin'];
    }
    if (array_key_exists('action', $action)) {
        $obj = $notice->__call('get' . ucfirst($action['action']));
        $notice->clear();
        if (is_object($obj)) {
            $rsl = $obj->__call('get' . ucfirst($action['get']));
            $obj->clear();
            echo "\n" . 'get' . ucfirst($action['get']) . ' : '  . number_format(memory_get_usage());
            $data .= $rsl;
            unset($rsl);
        } else {
            $data .='';
        }
        $obj = null;
    } else {
        $data .= $notice->__call('get' . ucfirst($action['get']));
        $notice->clear();
        echo "\n" . 'get' . ucfirst($action['get']) . ' : '  . number_format(memory_get_usage());
    }
    if (array_key_exists('end', $action)) {
        $data .= $action['end'];
    }
}
//--
class Notice{
    //--

    protected $instanceObj = null;

    public function __call($name, $arguments = null) {
        $this->instanceObj = $this->$name($arguments);
        return $this->instanceObj;
    }

    public function clear(){
         $this->instanceObj = null;
     }

    //--
}

An exemple of log file :

getField : 24,446,752
getField : 24,447,352
getField : 24,447,720
getField : 24,448,096
getField : 24,483,320
getField : 24,483,336
getField : 24,483,728
...
getField : 25,267,936
...
getField : 35,596,712
...

You can see the memory never stop to brows.

  • 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-06-18T02:39:52+00:00Added an answer on June 18, 2026 at 2:39 am

    The only solution is to sequence the script several execution. The problem is not PHP Symfony but generates too many objects. So I run the script Pacquet x. Otherwise it led to a saturation of memory.

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

Sidebar

Related Questions

I have a python script using the boto library on ec2 instance which is
I have a Perl script using a system call to sort a tsv file:
I have an f# script using Windows Forms and I want it to run
I have a script I'm using to convert English text to other spoken languages,
I have created a dynamic list picker script using Jquery 1.3 and PHP that
I have a batch file containing a python script using the Output template> %(NAME)s
I have been trying to make an init script using start-stop-daemon. I am stuck
Am creating a script using JQuery on an ASP.NET page. Have a JSON string
I have a Python script that is using some closed-box Python functions (i.e. I
I have a JScript script that runs using cscript.exe . It creates a shortcut

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.