I'm frankly not entirely sure what could be causing this. The script shouldn't really utilize that much memory. You're the very first in many years that appears to encounter this.
Could you try recording the client with the logger open, until it crashes? Such that perhaps you can catch the last message in the logger before it crashes and we might get some more info here.