Neural Network/Brain/node_modules/gpu.js/src/gpu.js
/**
   * @desc Destroys all memory associated with gpu.js & the webGl if we created it
   */
@desc Destroys all memory associated with gpu.js & the webGl if we created it
@desc Destroys all memory associated with gpu . js & the webGl if we created it
destroy() {
    if (!this.kernels) return;
    setTimeout(() => {
      for (let i = 0; i < this.kernels.length; i++) {
        this.kernels[i].destroy(true); 
      }
      let firstKernel = this.kernels[0];
      if (firstKernel) {
        if (firstKernel.kernel) {
          firstKernel = firstKernel.kernel;
        }
        if (firstKernel.constructor.destroyContext) {
          firstKernel.constructor.destroyContext(this.context);
        }
      }
    }, 0);
  }
destroy ( ) { if ( ! this . kernels ) return ; setTimeout ( ( ) => { for ( let i = 0 ; i < this . kernels . length ; i ++ ) { this . kernels [ i ] . destroy ( true ) ; } let firstKernel = this . kernels [ 0 ] ; if ( firstKernel ) { if ( firstKernel . kernel ) { firstKernel = firstKernel . kernel ; } if ( firstKernel . constructor . destroyContext ) { firstKernel . constructor . destroyContext ( this . context ) ; } } } , 0 ) ; }
@desc Destroys all memory associated with gpu.js & the webGl if we created it
@desc Destroys all memory associated with gpu . js & the webGl if we created it
// perform on next run loop - for some reason we dont get lose context events // if webGl is created and destroyed in the same run loop. // remove canvas if exists // all kernels are associated with one context, go ahead and take care of it here // if it is shortcut