hacker's fix of the memory problem when creating photon tracks. This is not properly tested, yet.

(cherry picked from commit 99afcadd11ab71d6f37da629ffe46f908e1570fe)