This method detaches off-heap memory from passed INDArray instances, and optionally stores them in cache for future reuse
PLEASE NOTE: Cache options depend on specific implementations

@param arrays
512631
@Override
    public void collect(INDArray... arrays) {
        // we basically want to free memory, without touching INDArray itself.
        // so we don't care when gc is going to release object: memory is already cached

        Nd4j.getExecutioner().commit();

        int cnt = -1;
        AtomicAllocator allocator = AtomicAllocator.getInstance();
        for (INDArray array : arrays) {
            cnt++;
            // we don't collect views, since they don't have their own memory
            if (array == null || array.isView())
                continue;

            AllocationPoint point = allocator.getAllocationPoint(array);

            if (point.getAllocationStatus() == AllocationStatus.HOST)
                allocator.getMemoryHandler().free(point, AllocationStatus.HOST);
            else if (point.getAllocationStatus() == AllocationStatus.DEVICE) {
                allocator.getMemoryHandler().free(point, AllocationStatus.DEVICE);
                allocator.getMemoryHandler().free(point, AllocationStatus.HOST);
            } else if (point.getAllocationStatus() == AllocationStatus.DEALLOCATED) {
                // do nothing
            } else
                throw new RuntimeException(
                                "Unknown AllocationStatus: " + point.getAllocationStatus() + " for argument: " + cnt);

            point.setAllocationStatus(AllocationStatus.DEALLOCATED);
        }
    }
372553
@Override
    public void touch(INDArray array) {
        if (array == null)
            return;

        touch(array.data());
        touch(array.shapeInfoDataBuffer());
    }
428974
public function flushArrays()
    {
        $this->_filesArray = null;
        $this->_imagesArray = null;
        $this->_foldersArray = null;
        $this->_filtersArray = null;
        $this->deleteHasCache(self::CACHE_KEY_FILE);
        $this->deleteHasCache(self::CACHE_KEY_IMAGE);
        $this->deleteHasCache(self::CACHE_KEY_FOLDER);
        $this->deleteHasCache(self::CACHE_KEY_FILTER);
    }
1360070
public void releaseAll() {
        synchronized(this) {
            Object[] refSet = allocatedMemoryReferences.values().toArray();
            if(refSet.length != 0) {
                logger.finer("Releasing allocated memory regions");
            }
            for(Object ref : refSet) {
                release((MemoryReference) ref);
            }
        }
    }
910399
protected void putBatch(Object[] objectArray) {

        int index = 0;
        synchronized (this) {
            while (index < objectArray.length && objectArray[index] != null) {
                put(objectArray[index]);
                index++;
            }
        }
        return;
    }
1249427
public static <T> Set<T> arrayToSet(final T[] array) {
        if (null == array) {
            return Collections.emptySet();
        }

        final Set<T> ret = new HashSet<T>();

        for (int i = 0; i < array.length; i++) {
            final T object = array[i];

            ret.add(object);
        }

        return ret;
    }
500402
def delete_arrays(self, period = None):
        

        self._memory_storage.delete(period)
        if self._disk_storage:
            self._disk_storage.delete(period)
563485
public static <E extends Comparable<E>> void quickSort(List<E> array) {
    if (array.isEmpty()) {
      return;
    }
    recursiveQuickSort(array, 0, array.size() - 1);
  }
133220
public static void clear(final double[][] m) {
    for(int i = 0; i < m.length; i++) {
      Arrays.fill(m[i], 0.0);
    }
  }
985083
public void putAll(ArrayMap<? extends K, ? extends V> array) {
        final int N = array.mSize;
        ensureCapacity(mSize + N);
        if (mSize == 0) {
            if (N > 0) {
                System.arraycopy(array.mHashes, 0, mHashes, 0, N);
                System.arraycopy(array.mArray, 0, mArray, 0, N<<1);
                mSize = N;
            }
        } else {
            for (int i=0; i<N; i++) {
                put(array.keyAt(i), array.valueAt(i));
            }
        }
    }
870724
protected function freezeArray(array &$array, array &$objects)
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                $this->freezeArray($value, $objects);
            } elseif (is_object($value)) {
                $tmp   = $this->freeze($value, $objects);
                $value = '__php_object_freezer_'.$tmp['root'];
                unset($tmp);
            }
        }
    }
1334084
@Override
    public T remove(int index) {
        /* Cache the value at the indicated position; this also does the bounds
         * check.
         */
        T result = get(index);

        /* Use a naive shuffle-down algorithm to reposition elements after
         * the removed one.
         */
        for (int i = index + 1; i < size(); ++i)
            set(i - 1, get(i));

        /* Clobber the last element to play nicely with the garbage collector. */
        set(size() - 1, null);

        /* Decrement our size. */
        --mSize;

        /* If we are now at 1/8 total capacity, shrink the structure. */
        if (size() * 8 <= mArrays.length * mArrays.length)
            shrink();
            /* Otherwise, if the size is now an even multiple of the array size,
             * we can drop the very last array.  This is the array whose offset
             * is one after the end of the elements.
             */
        else if (size() % mArrays.length == 0)
            mArrays[computeOffset(size())] = null;

        return result;
    }
1156818
public void clearMemory() {
        zeroArray(k);
        k = null;
        zeroArray(n);
        n = null;
        zeroArray(e);
        e = null;
        zeroArray(d);
        d = null;
        zeroArray(dp);
        dp = null;
        zeroArray(dq);
        dq = null;
        zeroArray(qi);
        qi = null;
        zeroArray(p);
        p = null;
        zeroArray(q);
        q = null;
        zeroArray(t);
        t = null;
        zeroArray(x);
        x = null;
        zeroArray(y);
        y = null;
    }
778542
private static void heapify(int[] arr) {
        int n = arr.length;
        for (int i = n / 2 - 1; i >= 0; i--)
            SortUtils.siftDown(arr, i, n - 1);
    }
1092555
protected static void checkNotNull (Object[] array)
    {
        checkNotNull((Object)array);
        for (Object o : array) {
            checkNotNull(o);
        }
    }
280510
public static void clearBufferArray(WsByteBuffer[] list) {
        if (list != null) {
            for (int i = 0; i < list.length; ++i) {
                if (list[i] != null)
                    list[i].clear();
            }
        }
    }
651024
void cleanupBoxedCache(int boxedAccessor) {
    for (int i = 0; i < boxedCache.length; i++)
      if (boxed[i][0] == boxedAccessor)
        boxedCache[i] = null;
  }