AllocatedMemoryIO allocate(Ruby runtime, int size, boolean clear) { MemoryAllocation allocation; Object sentinel; int idx = bucketIndex(roundUpToPowerOf2(Math.max(8, size))); AllocationGroup group = allocationGroups[idx]; if (group == null || (sentinel = group.get()) == null || (allocation = group.allocate(clear)) == null) { // no existing group, or it is all used up. allocationGroups[idx] = group = new AllocationGroup(buckets[idx].getMagazine(), sentinel = new Object()); referenceSet.put(group, Boolean.TRUE); allocation = group.allocate(clear); } return new AllocatedMemoryIO(runtime, sentinel, allocation, size); } }
synchronized void recycle() { if (fragmented) { int size = bucket.size; for (int i = 0; i < allocations.length; i++) { MemoryAllocation m = allocations[i]; if (m != null) { if (m.isUnmanaged()) { allocations[i] = null; } else { clearMemory(allocations[i].address, size); } } } fragmented = false; } nextIndex = 0; bucket.recycle(this); } }
synchronized void recycle() { if (fragmented) { int size = bucket.size; for (int i = 0; i < allocations.length; i++) { MemoryAllocation m = allocations[i]; if (m != null) { if (m.isUnmanaged()) { allocations[i] = null; } else { clearMemory(allocations[i].address, size); } } } fragmented = false; } nextIndex = 0; bucket.recycle(this); } }
synchronized void recycle() { if (fragmented) { int size = bucket.size; for (int i = 0; i < allocations.length; i++) { MemoryAllocation m = allocations[i]; if (m != null) { if (m.isUnmanaged()) { allocations[i] = null; } else { clearMemory(allocations[i].address, size); } } } fragmented = false; } nextIndex = 0; bucket.recycle(this); } }
synchronized void recycle() { if (fragmented) { int size = bucket.size; for (int i = 0; i < allocations.length; i++) { MemoryAllocation m = allocations[i]; if (m != null) { if (m.isUnmanaged()) { allocations[i] = null; } else { clearMemory(allocations[i].address, size); } } } fragmented = false; } nextIndex = 0; bucket.recycle(this); } }
AllocatedMemoryIO allocate(Ruby runtime, int size, boolean clear) { MemoryAllocation allocation; Object sentinel; int idx = bucketIndex(roundUpToPowerOf2(Math.max(8, size))); AllocationGroup group = allocationGroups[idx]; if (group == null || (sentinel = group.get()) == null || (allocation = group.allocate(clear)) == null) { // no existing group, or it is all used up. allocationGroups[idx] = group = new AllocationGroup(buckets[idx].getMagazine(), sentinel = new Object()); referenceSet.put(group, Boolean.TRUE); allocation = group.allocate(clear); } return new AllocatedMemoryIO(runtime, sentinel, allocation, size); } }
AllocatedMemoryIO allocate(Ruby runtime, int size, boolean clear) { MemoryAllocation allocation; Object sentinel; int idx = bucketIndex(roundUpToPowerOf2(Math.max(8, size))); AllocationGroup group = allocationGroups[idx]; if (group == null || (sentinel = group.get()) == null || (allocation = group.allocate(clear)) == null) { // no existing group, or it is all used up. allocationGroups[idx] = group = new AllocationGroup(buckets[idx].getMagazine(), sentinel = new Object()); referenceSet.put(group, Boolean.TRUE); allocation = group.allocate(clear); } return new AllocatedMemoryIO(runtime, sentinel, allocation, size); } }
AllocatedMemoryIO allocate(Ruby runtime, int size, boolean clear) { MemoryAllocation allocation; Object sentinel; int idx = bucketIndex(roundUpToPowerOf2(Math.max(8, size))); AllocationGroup group = allocationGroups[idx]; if (group == null || (sentinel = group.get()) == null || (allocation = group.allocate(clear)) == null) { // no existing group, or it is all used up. allocationGroups[idx] = group = new AllocationGroup(buckets[idx].getMagazine(), sentinel = new Object()); referenceSet.put(group, Boolean.TRUE); allocation = group.allocate(clear); } return new AllocatedMemoryIO(runtime, sentinel, allocation, size); } }