protected void zeroNativeMemory(final long size)
    {
        if (ptr != 0) {
            final int nthreads = (int)Math.min(size, Runtime.getRuntime().availableProcessors());
            if (nthreads <= 2 || size < 100000) {
                Utilities.UNSAFE.setMemory(ptr, size * sizeof, (byte) 0);
            } else {
                final long k = size / nthreads;
                final Thread[] threads = new Thread[nthreads];
                final long ptrf = ptr;
                for (int j = 0; j < nthreads; j++) {
                    final long firstIdx = j * k;
                    final long lastIdx = (j == nthreads - 1) ? size : firstIdx + k;
                    threads[j] = new Thread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            for (long k = firstIdx; k < lastIdx; k++) {
                                Utilities.UNSAFE.putByte(ptrf + sizeof * k, (byte) 0);
                            }
                        }
                    });
                    threads[j].start();
                }
                try {
                    for (int j = 0; j < nthreads; j++) {
                        threads[j].join();
                        threads[j] = null;
                    }
                } catch (final InterruptedException ex) {
                    Utilities.UNSAFE.setMemory(ptr, size * sizeof, (byte) 0);
                }
            }
        }
    }