If it refers to running memory (ram), press and hold the shutdown key to display sliding shutdown, and then press and hold the home key until you return to the home screen. I cleared all the backstage. It's no big deal!
If it refers to rom, it can only be cleared in the software, and the cache can be cleared. As for garbage, iOS is very clean, and software installation and uninstallation will not leave garbage.