# How much memory does a p5.Vector variable take up compared to an integer variable?

**URL:** <https://discourse.processing.org/t/how-much-memory-does-a-p5-vector-variable-take-up-compared-to-an-integer-variable/19681>\
**Category:** Coding Questions\
**Created:** [April 12, 2020, 12:29am UTC](https://discourse.processing.org/t/how-much-memory-does-a-p5-vector-variable-take-up-compared-to-an-integer-variable/19681 "2020-04-12T00:29:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bassam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@Bassam](https://discourse.processing.org/u/Bassam)\
**Post date:** [April 12, 2020, 12:29am UTC](https://discourse.processing.org/t/how-much-memory-does-a-p5-vector-variable-take-up-compared-to-an-integer-variable/19681/1 "2020-04-12T00:29:45Z")

</div>

I’m writing something that involves image manipulation. I decided to use an array of p5.Vectors because I could store the x and y coordinates of pixels more easily. I could just as easily create 2 integer arrays (coordinateX and coordinateY) that would do the same thing.

I do want to be efficient and not take up computer resources unnecessarily.

Should I switch from the p5.Vector array to 2 integer arrays instead?

Thanks.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 12, 2020, 12:42am UTC](https://discourse.processing.org/t/how-much-memory-does-a-p5-vector-variable-take-up-compared-to-an-integer-variable/19681/2 "2020-04-12T00:42:19Z")

</div>

> [@Bassam](#):
>
> Should I switch from the p5.Vector array to 2 integer arrays instead?

If you’re not invoking any of the p5.Vector’s methods there’s not much reason to use it.

You can simply go w/ an Uint16Array for example:

> **[Uint16Array - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array)**
>
> The Uint16Array typed array represents an array of 16-bit unsigned integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0. Once established, you can reference elements in the...

You can store all the _x_ values in the even indices, and all the _y_ values in the odd indices.
