I seriously doubt that this would cause a memory leak, but that code sample suggests that $id and $data aren't needed outside the while loop. I always try to put variables in the innermost scope that they are needed.
I'd have thought so too, but the program hangs on one record, and I can bring up top and watch the process start eating memory until the machine hangs.