haXe Forum > Reusing objects on flash?

  • I'm making a particle engine for my game, and I was wondering, should I reuse my particle objects rather than destroying old and creating new ones?

    I'm targeting the flash platform. What is the general wisdom of this?

  • Reuse as much as you can.
    Constructor is the slowest function of the object because it is never "JITed" - evaluated each time anew. Besides, GC won't collect all the unused objects all at once, it may take time before it kicks in. Flash may be very not precise when allocating memory to objects, usually it'll allocate much more then needed and it will take time to free that memory. Besides, GC isn't super-fast, so, if there are many objects to remove you may experience visual lags when that happens.

< Prev | Page 1 / 1 | Next >