How can the Garbage Collector impact memory usage in PHP scripts and what are the best practices for managing memory in long-running scripts?

The Garbage Collector in PHP can impact memory usage by automatically freeing up memory that is no longer in use. To manage memory in long-running scripts, it is important to unset variables that are no longer needed and free up memory manually when possible.

// Example of unsetting variables to free up memory
$largeArray = range(1, 1000000);
// Process data
unset($largeArray);