# How to dispose BufferAttribute Array on updates?

**URL:** <https://discourse.threejs.org/t/how-to-dispose-bufferattribute-array-on-updates/11044>\
**Category:** Questions\
**Tags:** buffergeometry\
**Created:** [November 25, 2019, 8:50pm UTC](https://discourse.threejs.org/t/how-to-dispose-bufferattribute-array-on-updates/11044 "2019-11-25T20:50:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thissushiguy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/thissushiguy/32/11150_2.png) [@Thissushiguy](https://discourse.threejs.org/u/Thissushiguy)\
**Post date:** [November 25, 2019, 8:50pm UTC](https://discourse.threejs.org/t/how-to-dispose-bufferattribute-array-on-updates/11044/1 "2019-11-25T20:50:30Z")

</div>

We are trying to update a BufferAttribute with new position data. We want to dispose it on upload. When the buffer gets created, we utilize onUploadCallback to dispose the array data on CPU. We were expecting onUploadCallback to be called during update as well. It appears it is not. Currently, our work around is to create a new BufferAttribute since it calls the onUploadCallback.

We were wondering if WebGLAttributes.update should also call onUploadCallback or if our current approach is correct ?

Thanks !

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [November 26, 2019, 12:06pm UTC](https://discourse.threejs.org/t/how-to-dispose-bufferattribute-array-on-updates/11044/2 "2019-11-26T12:06:11Z")

</div>

> [@Thissushiguy](#):
>
> We were wondering if WebGLAttributes.update should also call onUploadCallback

I think it’s okay to enhance `WebGLAttributes.update()` so this behavior is true. I see no reason why an update of an existing buffer should not execute `onUploadCallback()`. In both cases, data are uploaded to the GPU and user might want to free the reference to `BufferAttribute.array`.

Do you want to make a PR with this proposal?

---

<div class="post-metadata">

**Author:** ![Thissushiguy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/thissushiguy/32/11150_2.png) [@Thissushiguy](https://discourse.threejs.org/u/Thissushiguy)\
**Post date:** [November 27, 2019, 7:36pm UTC](https://discourse.threejs.org/t/how-to-dispose-bufferattribute-array-on-updates/11044/3 "2019-11-27T19:36:51Z")

</div>

Thanks for your guidance.  
I created [https://github.com/mrdoob/three.js/pull/18016](https://github.com/mrdoob/three.js/pull/18016)
