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

The Archive Base Latest Questions

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

Ok, so I am looking for a way to unset ALL variables generated by

  • 0

Ok, so I am looking for a way to unset ALL variables generated by a page but NOT global variables or Sessions.

I found this in another SO question:

$list_of_vars =  array_diff(get_defined_vars(), $GLOBALS); // Was just get_defined_vars() before Marc B corrected me in his post.
foreach($list_of_vars as $var){
    unset($var);
}

The thing is that in the comments it was said that this unsets() ALL as in ALL variables the include globals and Sessions. I need a way to reset all variables that are NOT global and NOT Sessions

I am doing this for optimizing RAM. If this doesn’t help then, is there any other way of optimizing RAM?

  • 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-13T07:39:52+00:00Added an answer on June 13, 2026 at 7:39 am

    This is definitely not the way to go to optimize your script’s RAM usage.

    You want to identify the problem areas of your script, and work on those.

    It’s hard to give any hints without knowing what your script does. Here are some pointers to discussion on SO (partly very high-level and/or Framework-specific, but they still contain valuable info):

    • How to optimize the php process memory usage? (if you have the option to install new software to aid your PHP processes)

    • Optimize my performance

    • Simple but heavy application consuming a lot of resources. How to Optimize? (about mySQL usage optimization really)

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

Sidebar

Related Questions

I'm looking a way to enable IP logging with log4net in ASP.NET. I found
I'm looking for way to write Javascript programs / scripts on desktop, not inside
First, I'm not looking a way to parse an RSS-feed. I am creating an
looking a way to make a toggle on doubleclick, this is my code: $('#mydiv').toggle(function()
The following pseudo code does not work the way I expect and I'm looking
I am looking a way to set CommandTimeout for DbContext. After searching I found
I'm looking the way to read all assemblies (.dlls) used by my app. In
Forgive the ignorance of this question, as I'm completely new to C#, but how
I'm looking for way in Fluent NHibernate to get a list of all object
I am looking for a way to load an array from another class, as

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.