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?