To figure out which files use the most memory, you will need to use PHP memory profiling tools. You can find more info about them here: PHP memory profiling
General profiling tools might also be useful: Simplest way to profile a PHP script
Also, 5GB is a very small amount of memory for a server, especially if you have 25k+ visitors a day. I honestly doubt it's possible to optimize a PHP script so much, that it would run smoothly for 25k visitors on just 5GB of RAM. Just think about it this way - if you have a 1000 visitors at the same time (with 25k a day, your peak might even be higher) then each user will only have 5mb of memory, which is not enough to even start an Apache instance, so of course the server will slow down, until memory is freed up.
My first step in this situation would be to upgrade a server and only then bother with profiling.