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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:23:29+00:00 2026-05-26T04:23:29+00:00

I have read for years about ways to conserve memory when writing php scripts.

  • 0

I have read for years about ways to conserve memory when writing php scripts. But what type of scripts should I really concern myself with. What codes/scripts/call eat the most memory?

Edit

This is a question, please do not answer it with a question

Edit

What about this. Does something like this eat memory? It needs to be done but should it be freed some how?

$manufacture = htmlspecialchars($_REQUEST["manufacture"]);
$manufacture = preg_replace("/[^0-9]/","", $manufacture);



$SQL = "SELECT * FROM STORE_MANUFACTURERS WHERE manufacturers_id = '$manufacture'";
$result = mysql_query( $SQL );
while( $row = mysql_fetch_array( $result ) ) {
$manufacturers_name = $row['manufacturers_name'];
}
  • 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-26T04:23:30+00:00Added an answer on May 26, 2026 at 4:23 am

    There are so many things to think when you go for a 100% perfect out look regarding memory leak. What I do is to follow the coding standards and patterns . and if I get into memory leak trouble even after that I should figure that out with profiling Tools like XDebug or Kcachegrind.

    Things Like Exception safety should be well maintained

    You can use tools like memory_get_peak_usage() , memory_get_usage() to spot the culprit. You may check out this post regarding Memory Manager.

    Scripting Languages like PHP uses automatic garbage collection e.g. you don’t have to dealloc by yourself. the garbage collector does it for you (using reference counting). but if you want to do it by yourself you may use unset(). but some scenarios has been reported when even unset doesn’t do it for you. Some Bugs have been reported regarding this too. bug#33945 bug#33487

    reference counting will run into problem when both a:A and b:B have a circular reference so you need the one instance to take the ownership and destruct the referred object to break the circle to face this issue.

    There are some issues with strtotime() memory leak bug#47285

    The code you have posted in your edit shouldn’t have any concern of having memory leak. I’ll quote @GolezTrol in comments

    All memory allocated by the script is freed as soon as it terminates,
    which is at the end of each request. You shouldn’t really have any
    concerns unless you are building special scripts or have a website
    with a very high load. If you have to have this question like this,
    you probably have neither, so don’t worry about it.

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

Sidebar

Related Questions

I have a question about Java style. I've been programming Java for years, but
I have read about partial methods in the latest C# language specification , so
I have read this post about how to test private methods. I usually do
I have been working with PHP for years and gotten a very good grasp
In the past few years I have read plenty of articles on Foreign Keys
For years, maybe 10, I've been fascinated with cryptography. I read a book about
I once read a page a few years ago about the various browsers' differing
I've read the Apple doc about Preferences but this is still a little bit
I have Emacs open but accidentally I've deleted the .emacs file it read when
I have read through several reviews on Amazon and some books seem outdated. I

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.