(long address, long oldSize, long newSize, int memoryTag)
| 408 | } |
| 409 | |
| 410 | public static long realloc(long address, long oldSize, long newSize, int memoryTag) { |
| 411 | try { |
| 412 | assert memoryTag >= MemoryTag.NATIVE_PATH; |
| 413 | checkAllocLimit(-oldSize + newSize, memoryTag); |
| 414 | long ptr = UNSAFE.reallocateMemory(address, newSize); |
| 415 | recordMemAlloc(-oldSize + newSize, memoryTag); |
| 416 | incrReallocCount(); |
| 417 | return ptr; |
| 418 | } catch (OutOfMemoryError oom) { |
| 419 | CairoException e = CairoException.nonCritical().setOutOfMemory(true) |
| 420 | .put("sun.misc.Unsafe.reallocateMemory() OutOfMemoryError [RSS_MEM_USED=") |
| 421 | .put(getRssMemUsed()) |
| 422 | .put(", oldSize=") |
| 423 | .put(oldSize) |
| 424 | .put(", newSize=") |
| 425 | .put(newSize) |
| 426 | .put(", memoryTag=").put(memoryTag) |
| 427 | .put("], original message: ") |
| 428 | .put(oom.getMessage()); |
| 429 | System.err.println(e.getFlyweightMessage()); |
| 430 | throw e; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | public static void recordMemAlloc(long size, int memoryTag) { |
| 435 | assert memoryTag >= 0 && memoryTag < MemoryTag.SIZE; |
no test coverage detected