# How to clear the array (this.array) of the bufferAttribute which is shared with different geometries

**URL:** <https://discourse.threejs.org/t/how-to-clear-the-array-this-array-of-the-bufferattribute-which-is-shared-with-different-geometries/3942>\
**Category:** Questions\
**Tags:** buffergeometry\
**Created:** [August 29, 2018, 9:27am UTC](https://discourse.threejs.org/t/how-to-clear-the-array-this-array-of-the-bufferattribute-which-is-shared-with-different-geometries/3942 "2018-08-29T09:27:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kutti45](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/kutti45/32/2519_2.png) [@kutti45](https://discourse.threejs.org/u/kutti45)\
**Post date:** [August 29, 2018, 9:27am UTC](https://discourse.threejs.org/t/how-to-clear-the-array-this-array-of-the-bufferattribute-which-is-shared-with-different-geometries/3942/1 "2018-08-29T09:27:45Z")

</div>

can anyone help me out, how to clear the array (this.array) of the bufferAttribute which is shared with different geometries. i tried with “onUploadCallback” but it throwing error for this case.

```auto
getBufferAttrib(accessor)
{
let key ='bufferView : ' + accessor.bufferView;
let bufferAttribute = this.BufferAttributeCache.get(key);

if(bufferAttribute === undefined){

   let itemSize = WebglConstants.WEBGL_TYPE_SIZES[accessor.type];

   let arrayType = WebglConstants.WEBGL_COMPONENT_TYPES[accessor.componentType];
   let data = new arrayType(accessor.bufferViewData,accessor.bufferOffset, accessor.count * itemSize );
   bufferAttribute = new THREE.BufferAttribute( data, itemSize );    
   bufferAttribute.name = accessor.name;
   bufferAttribute.refCount = 1;
   bufferAttribute.onUploadCallback = function() {
       this.refCount = this.refCount - 1;
       if(this.refCount === 0){
           this.array = null;
       }             
   };      
   this.BufferAttributeCache.add(key, bufferAttribute);

}
else{
   bufferAttribute.refCount = bufferAttribute.refCount + 1;
}

```

---

<div class="post-metadata">

**Author:** ![TheJim01](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/thejim01/32/2007_2.png) [@TheJim01](https://discourse.threejs.org/u/TheJim01)\
**Post date:** [August 29, 2018, 1:15pm UTC](https://discourse.threejs.org/t/how-to-clear-the-array-this-array-of-the-bufferattribute-which-is-shared-with-different-geometries/3942/2 "2018-08-29T13:15:32Z")

</div>

Please reformat your code–it did not format correctly for this forum. Also, [as I mentioned on Stack Overflow](https://stackoverflow.com/questions/52073823/how-to-clear-the-array-this-array-of-the-bufferattribute-which-is-shared-with), if you’re receiving an error, please include the full text of the error in your question (or on this forum you can post it below as a reply).
