# Single array or multiple arrays?

**URL:** <https://forum.kirupa.com/t/single-array-or-multiple-arrays/330591>\
**Category:** flash\
**Created:** [February 14, 2013, 5:36pm UTC](https://forum.kirupa.com/t/single-array-or-multiple-arrays/330591 "2013-02-14T17:36:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![John4213](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@John4213](https://forum.kirupa.com/u/John4213)\
**Post date:** [February 14, 2013, 5:36pm UTC](https://forum.kirupa.com/t/single-array-or-multiple-arrays/330591/1 "2013-02-14T17:36:13Z")

</div>

Hello, does anyone know what’s better for performance, a single array controlling most events or multiple arrays for each different event? In a game I’m making I have 2 arrays, one controlling the fire and one controlling the particles (falling debris etc), here’s an example of the code so far:

**Fire array**

```auto
for (var XXX=0; XXX<array_fire.length; XXX++)
{
    if (array_fire[XXX].removal >= 40)
    {
        duplicates.removeChild(array_fire[XXX]);
        array_fire.splice(XXX,1);
    }
    else
    {
        array_fire[XXX].y -= 2;
        array_fire[XXX].removal++;
    }
}

```

**Particle array**

```auto
for (var XXX=0; XXX<array_physics.length; XXX++)
{
    array_physics[XXX].y += array_physics[XXX].y_speed / 10;
    array_physics[XXX].x += array_physics[XXX].x_speed;
    if (array_physics[XXX].y <= 1000)
    {
        duplicates.removeChild(array_physics[XXX]);
        array_physics.splice(XXX,1);
    }
}

```

As far as I’m aware a single array would be better to minimize memory usage but I don’t know if a single array is better to ensure the best performance.

Thank you for reading and thanks for your input 🙂
