This memory leak will only be a problem if it destroys the script with an "exhausted memory" error. PHP will be happy to collect any unusual objects / variables on its own, but the collector will not kick until it is needed - garbage collection can be a very expensive operation.
It is normal to see a rise in memory usage, even if you constantly reuse the same objects / variables - this is not until the memory usage has exceeded a certain level that the collector will start and clean at home.
I suspect that you can do something a lot faster if you have grouped user IDs and released fewer updates, changing entries every time. For example, follow these steps:
UPDATE user_roundscores SET ursUpdDate=NOW() WHERE ursUserTeamIdFK IN (id1, id2, id3, id4, id5, etc...)
instead of doing this one update to the user. Fewer rounds through the DB interface layer and more server time = faster startup.
Weβll also consider the impact of expanding this on millions of users now, as you say in the commentary. For millions of individual updates, it will take a non-trivial amount of time to run, so NOW() will not be a βconstantβ. If it takes 5 minutes to fully run, you will get a wide selection of ursUpdDate . You might want to consider caching a single NOW() call in a server-side variable and issue updates for this variable:
SELECT @cachednow :p NOW(); UPDATE .... SET ursUpDate = @cachednow WHERE ....;
source share