In terms of automatic memory management, PHP uses reference counting whereas Java uses garbage collection. So the runtime performance of PHP already includes the cost of memory management, but a tragic consequence of garbage collection in Java is that you can not predict when it will take place.