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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:12:35+00:00 2026-06-17T20:12:35+00:00

This relates to a PHP 5.3 Cli application that processes a lot of data

  • 0

This relates to a PHP 5.3 Cli application that processes a lot of data in a complex way, taking hours to run. Someone discovered that turning off garbage collection made it run a great deal faster (maybe as much as 50%).

The only article I’ve come across that mentions this performance hit is http://derickrethans.nl/collecting-garbage-performance-considerations.html. I’m not sure I follow it entirely, but it seems to suggest that it only applies to code with a lot of circular references.

Could someone shed some light on this please?

Also, given that we have turned gc off, is there any way to manually reduce memory? Using unset() has been suggested. A quick test has shown that eighty or so bytes is freed by unset() regardless of the size of the object. This suggests it’s just unsetting the reference, which is borne out by what I have read online. Am I right in thinking that these eighty bytes would be freed anyway, even without garbage collection, when the variable falls out of scope?

  • 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-17T20:12:36+00:00Added an answer on June 17, 2026 at 8:12 pm

    You just disabled the circular-reference-GC. The regular one still works.

    The common GC tests, whether or not there are zvals (“memory”), that are not referenced by any variables, or properties anymore, and will free this memory. A circular reference is, when two or more objects references each other directly, or indirectly

    $a = new stdClass;
    $b = new stdClass;
    $a->b = $b;
    $b->a = $a;
    unset($a, $b);
    

    Now both objects reference each other, but they are both not referenced from anywhere else, so they are unreachable. This is, what the circular-reference GC tries to detect, but to find them, it iterates over every known object and finds out, if there is a reference “from outside”. Its a little bit more complicated, but simplified thats it 😉 So in structures with many references, espcially circular ones, it is a huge task.

    Worth to mention: With unset() you only remove the reference, but don’t free the memory (directly). This is done by the GC later (and it makes a good job :))

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

Sidebar

Related Questions

This relates to Composite Application Guidance for WPF, or Prism. I have one MainRegion
This relates to my other question on accessing a REST service that uses forms
This question relates to: PHP Version 5.3.6 Microsoft Drivers for PHP for SQL Server
This post relates to a previous that i posted but the question is different
This relates to the question in: conditional DirectoryIndex in .htaccess The answer states that
We have a bunch of cli cron style scripts that are coded in php.
I've got a lot of mysql data that I need to generate reports from.
This question specifically relates to my experience with PHP, but there's no reason why
I got this from php.net website. This is related to the problem I am
This question is related to another question I wrote: Trouble using DOTNET from PHP.

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.