Running out of memory

I have an issue with my Multiplayer Treasure Grove code where it consistently runs out of memory and crashes the tab. I’m not calling this a bug since it may well be a problem with my code. The function that is causing problems is:

def inBox(box,items):
  retv = []
    for item in items:
      if item.pos.x > box['left'] and item.pos.x < box['right']: #...removed for brevity 
  return retv

Simple enough, but I have concerns that the return value(s) from this function are being saved for each frame. and don’t see how I could be running out of memory otherwise. I think that I could switch to 64 bit chrome and make this go away, but since its for a multiplayer level it ultimately needs to be simulated by other users that are by and large running 32 bit browsers. So my questions:

  1. What are the rules for determining if something is going to be retained on a per frame basis?
  2. Are these rules different for the simulation client?
  3. Is there a way that I can simulate a specific match (with the simulation client) to see if there are issues?

Do you see the same problem if you add a &skip_protect_api=true query parameter to your Multiplayer Treasure Grove play URL? (This should disable any sort of flow tracking, which sounds like it might be the issue.)