Tracking Memory Usage in PHP

I’m trying to track the memory usage of a script that processes URLs. The basic idea is to check that there’s a reasonable buffer before adding another URL to a cURL multi handler. I’m using a ‘rolling cURL’ concept that processes a URLs data as the multi handler is running. This means I can keep N connections active by adding a new URL from a pool each time an existing URL processes and is removed.