| 322 | } |
| 323 | |
| 324 | public static long malloc(long size, int memoryTag) { |
| 325 | try { |
| 326 | assert memoryTag >= MemoryTag.NATIVE_PATH; |
| 327 | checkAllocLimit(size, memoryTag); |
| 328 | long ptr = UNSAFE.allocateMemory(size); |
| 329 | recordMemAlloc(size, memoryTag); |
| 330 | incrMallocCount(); |
| 331 | return ptr; |
| 332 | } catch (OutOfMemoryError oom) { |
| 333 | CairoException e = CairoException.nonCritical().setOutOfMemory(true) |
| 334 | .put("sun.misc.Unsafe.allocateMemory() OutOfMemoryError [RSS_MEM_USED=") |
| 335 | .put(getRssMemUsed()) |
| 336 | .put(", size=") |
| 337 | .put(size) |
| 338 | .put(", memoryTag=").put(memoryTag) |
| 339 | .put("], original message: ") |
| 340 | .put(oom.getMessage()); |
| 341 | System.err.println(e.getFlyweightMessage()); |
| 342 | throw e; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | public static long objectFieldOffset(Field f) { |
| 347 | return UNSAFE.objectFieldOffset(f); |