in reply to WHY copying does happen (fork)

- WHAT can I do to avoid it

In addition to what Corion said, you should also avoid implicit type conversions (e.g. number to string), or - if they can't be avoided - force them before doing the fork...

(also see fork(): where does copy happen?)