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

  • Home
  • SEARCH
  • 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 8871371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:58:33+00:00 2026-06-14T17:58:33+00:00

I am a novice PHP developer and in the process of learning this great

  • 0

I am a novice PHP developer and in the process of learning this great language. I now end up having a script consisting of 1,343,579 lines and when I try to run this I am getting the following:

Fatal error: Out of memory (allocated 269221888) (tried to allocate 536870912 bytes) in Unknown on line 0

I have a same piece of code being repeated 512 times because I am allowing 2^9 different combinations accounting for different Search Options. I am trying my best to minimise memory leak by using unset(), nulling variables and sometimes explicitly calling the gc_collect_cycles().

Would you please let me know whether 1 million line code will simply end up having this memory problem OR I am doing something silly in relation to memory management.

  • 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-14T17:58:35+00:00Added an answer on June 14, 2026 at 5:58 pm

    Split up your source into smaller parts and include only what you really need. When you repeat the same thing over and over again, refactor this into a separate function and call it with appropriate parameters.

    Without knowing the concrete task, we cannot give more advice.

    You can build your query string gradually depending on your conditions

    function execute_query($pdo, $cond1, $cond2, $cond3, ..., $cond9)
    {
        $params = array();
        $bind_types = '';
        $sql = 'select * from mytable where';
    
        $sql = "$sql condition1 = ?";
        $params[] = $cond1;
    
        if (isset($cond2)) {
            $sql = "$sql and condition2 = ?";
            $params[] = $cond2;
        }
    
        if (isset($cond3)) {
            $sql = "$sql and condition3 = ?";
            $params[] = $cond3;
        }
    
        ...
    
        $sth = $pdo->prepare($sql);
        return $sth->execute($params);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a PHP novice, and I recently found this database-free pagination script on a
I'm a novice php programmer and having a problem assembling this code to work.
Php novice. 1.Is there anything wrong with this PHP & MySQL code? include_once db_login.php
I'm a mac novice and trying to get a developer setup to develop php
complete Novice to PHP and HTML so this could be a schoolboy error. I'm
This is a part of PHP & MySQL Novice to Ninja, 5th Edition by
I am new to PHP. In the path of learning PHP language, I notice
First off, I'm a complete novice as a web developer. I have a PHP
I am a Cake PHP novice. I want to edit the table Issue. This
I'm a novice when it comes to SQL and PHP, and I'm trying to

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.