Allocate space in the native heap via a call to C's malloc . @param size number of bytes of space to allocate
(long size)
| 110 | * @param size number of <em>bytes</em> of space to allocate |
| 111 | */ |
| 112 | public Memory(long size) { |
| 113 | this.size = size; |
| 114 | if (size <= 0) { |
| 115 | throw new IllegalArgumentException("Allocation size must be greater than zero"); |
| 116 | } |
| 117 | peer = malloc(size); |
| 118 | if (peer == 0) |
| 119 | throw new OutOfMemoryError("Cannot allocate " + size + " bytes"); |
| 120 | |
| 121 | allocatedMemory.put(peer, new WeakReference<>(this)); |
| 122 | cleanable = Cleaner.getCleaner().register(this, new MemoryDisposer(peer)); |
| 123 | } |
| 124 | |
| 125 | protected Memory() { |
| 126 | super(); |
nothing calls this directly
no test coverage detected