You need to tell us about request per seconds you get (turn on mod_status in lighttpd set fast fastcgi.debug = 1 and monitor error log file to get exact load of php. How did you find out that lighttpd is eating all memory? What is output of the following?
Code:
ps aux | grep php
w
atop