java.lang.OutOfMemoryError.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中java.lang.OutOfMemoryError.getMessage()方法的一些代码示例,展示了OutOfMemoryError.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutOfMemoryError.getMessage()方法的具体详情如下:
包路径:java.lang.OutOfMemoryError
类名称:OutOfMemoryError
方法名:getMessage

OutOfMemoryError.getMessage介绍

暂无

代码示例

代码示例来源:origin: org.apache.spark/spark-core_2.11

public SparkOutOfMemoryError(OutOfMemoryError e) {
    super(e.getMessage());
  }
}

代码示例来源:origin: org.apache.spark/spark-core

public SparkOutOfMemoryError(OutOfMemoryError e) {
    super(e.getMessage());
  }
}

代码示例来源:origin: neo4j/neo4j

private OutOfMemoryError error( long length, int itemSize, OutOfMemoryError error )
{
  return Exceptions.withMessage( error, format( "%s: Not enough memory available for allocating %s, tried %s",
      error.getMessage(), bytes( length * itemSize ), Arrays.toString( candidates ) ) );
}

代码示例来源:origin: apache/geode

public static long allocate(int size) {
 if (unsafe == null) {
  throw new OutOfMemoryError("Off-heap memory is not available because: " + reason);
 }
 try {
  return unsafe.allocateMemory(size);
 } catch (OutOfMemoryError err) {
  String msg = "Failed creating " + size + " bytes of off-heap memory during cache creation.";
  if (err.getMessage() != null && !err.getMessage().isEmpty()) {
   msg += " Cause: " + err.getMessage();
  }
  if (!SharedLibrary.is64Bit() && size >= (1024 * 1024 * 1024)) {
   msg +=
     " The JVM looks like a 32-bit one. For large amounts of off-heap memory a 64-bit JVM is needed.";
  }
  throw new OutOfMemoryError(msg);
 }
}

代码示例来源:origin: graphhopper/graphhopper

@Override
public boolean ensureCapacity(long bytes) {
  if (bytes < 0)
    throw new IllegalArgumentException("new capacity has to be strictly positive");
  long cap = getCapacity();
  long newBytes = bytes - cap;
  if (newBytes <= 0)
    return false;
  int segmentsToCreate = (int) (newBytes / segmentSizeInBytes);
  if (newBytes % segmentSizeInBytes != 0)
    segmentsToCreate++;
  try {
    byte[][] newSegs = Arrays.copyOf(segments, segments.length + segmentsToCreate);
    for (int i = segments.length; i < newSegs.length; i++) {
      newSegs[i] = new byte[1 << segmentSizePower];
    }
    segments = newSegs;
  } catch (OutOfMemoryError err) {
    throw new OutOfMemoryError(err.getMessage() + " - problem when allocating new memory. Old capacity: "
        + cap + ", new bytes:" + newBytes + ", segmentSizeIntsPower:" + segmentSizePower
        + ", new segments:" + segmentsToCreate + ", existing:" + segments.length);
  }
  return true;
}

代码示例来源:origin: graphhopper/graphhopper

@Override
public boolean ensureCapacity(long bytes) {
  if (bytes < 0)
    throw new IllegalArgumentException("new capacity has to be strictly positive");
  long cap = getCapacity();
  long newBytes = bytes - cap;
  if (newBytes <= 0)
    return false;
  int segmentsToCreate = (int) (newBytes / segmentSizeInBytes);
  if (newBytes % segmentSizeInBytes != 0)
    segmentsToCreate++;
  try {
    int[][] newSegs = Arrays.copyOf(segments, segments.length + segmentsToCreate);
    for (int i = segments.length; i < newSegs.length; i++) {
      newSegs[i] = new int[1 << segmentSizeIntsPower];
    }
    segments = newSegs;
    return true;
  } catch (OutOfMemoryError err) {
    throw new OutOfMemoryError(err.getMessage() + " - problem when allocating new memory. Old capacity: "
        + cap + ", new bytes:" + newBytes + ", segmentSizeIntsPower:" + segmentSizeIntsPower
        + ", new segments:" + segmentsToCreate + ", existing:" + segments.length);
  }
}

代码示例来源:origin: steelkiwi/cropiwa

private static Bitmap transformBitmap(@NonNull Bitmap bitmap, @NonNull Matrix transformMatrix) {
  Bitmap result = bitmap;
  try {
    Bitmap converted = Bitmap.createBitmap(
        bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(),
        transformMatrix,
        true);
    if (!bitmap.sameAs(converted)) {
      result = converted;
      bitmap.recycle();
    }
  } catch (OutOfMemoryError error) {
    CropIwaLog.e(error.getMessage(), error);
  }
  return result;
}

代码示例来源:origin: apache/hive

void init(int arenaIx) {
 this.arenaIx = arenaIx;
 try {
  data = preallocateArenaBuffer(arenaSize);
 } catch (OutOfMemoryError oom) {
  throw new OutOfMemoryError("Cannot allocate " + arenaSize + " bytes: " + oom.getMessage()
    + "; make sure your xmx and process size are set correctly.");
 }
 int maxMinAllocs = 1 << (arenaSizeLog2 - minAllocLog2);
 buffers = new LlapAllocatorBuffer[maxMinAllocs];
 headers = new byte[maxMinAllocs];
 int allocLog2Diff = maxAllocLog2 - minAllocLog2, freeListCount = allocLog2Diff + 1;
 freeLists = new FreeList[freeListCount];
 for (int i = 0; i < freeListCount; ++i) {
  freeLists[i] = new FreeList();
 }
 int maxMaxAllocs = 1 << (arenaSizeLog2 - maxAllocLog2),
   headerIndex = 0, headerStep = 1 << allocLog2Diff;
 freeLists[allocLog2Diff].listHead = 0;
 for (int i = 0, offset = 0; i < maxMaxAllocs; ++i, offset += maxAllocation) {
  setHeaderFree(headerIndex, allocLog2Diff, CasLog.Src.CTOR);
  data.putInt(offset, (i == 0) ? -1 : (headerIndex - headerStep));
  data.putInt(offset + 4, (i == maxMaxAllocs - 1) ? -1 : (headerIndex + headerStep));
  headerIndex += headerStep;
 }
}

代码示例来源:origin: wildfly/wildfly

@Override
public ActiveMQBuffer createTransportBuffer(final int size) {
 try {
   return new ChannelBufferWrapper(channel.alloc().directBuffer(size), true);
 } catch (OutOfMemoryError oom) {
   final long totalPendingWriteBytes = batchBufferSize(this.channel, this.writeBufferHighWaterMark);
   // I'm not using the ActiveMQLogger framework here, as I wanted the class name to be very specific here
   logger.warn("Trying to allocate " + size + " bytes, System is throwing OutOfMemoryError on NettyConnection " + this + ", there are currently " + "pendingWrites: [NETTY] -> " + totalPendingWriteBytes + "[EVENT LOOP] -> " + pendingWritesOnEventLoopView.get() + " causes: " + oom.getMessage(), oom);
   throw oom;
 }
}

代码示例来源:origin: h2oai/h2o-2

private static ByteBuffer bbMake() {
 while( true ) {             // Repeat loop for DBB OutOfMemory errors
  ByteBuffer bb;
  try { bb = BBS.pollFirst(0,TimeUnit.SECONDS); }
  catch( InterruptedException e ) { throw Log.errRTExcept(e); }
  if( bb != null ) {
   bbstats(BBCACHE);
   return bb;
  }
  try {
   bb = ByteBuffer.allocateDirect(BBSIZE).order(ByteOrder.nativeOrder());
   bbstats(BBMAKE);
   return bb;
  } catch( OutOfMemoryError oome ) {
   // java.lang.OutOfMemoryError: Direct buffer memory
   if( !"Direct buffer memory".equals(oome.getMessage()) ) throw oome;
   System.out.println("Sleeping & retrying");
   try { Thread.sleep(100); } catch( InterruptedException ignore ) { }
  }
 }
}
private static void bbFree(ByteBuffer bb) {

代码示例来源:origin: stanfordnlp/CoreNLP

@Override
public boolean hasNext() {
 // Still have elements in this block
 if (elements.hasNext()) return true;
 // Still have files to traverse
 elements = null;
 while (index < files.length && elements == null) {
  try {
   elements = readBlock(files[index]).iterator();
  } catch (OutOfMemoryError e) {
   warn("FileBackedCache", "Caught out of memory error (clearing cache): " + e.getMessage());
   FileBackedCache.this.clear();
   //noinspection EmptyCatchBlock
   try { Thread.sleep(1000); } catch (InterruptedException e2) {
    throw new RuntimeInterruptedException(e2);
   }
   elements = readBlock(files[index]).iterator();
  } catch (RuntimeException e) {
   err(e);
  }
  index += 1;
 }
 // No more elements
 return elements != null && hasNext();
}
@Override

代码示例来源:origin: graphhopper/graphhopper

final boolean ensureCapacity(long bytes, boolean clearNewMem) {
  long oldCap = getCapacity();
  long newBytes = bytes - oldCap;
  if (newBytes <= 0)
    return false;
  // avoid frequent increase of allocation area, instead increase by segment size
  int allSegments = (int) (bytes / segmentSizeInBytes);
  if (bytes % segmentSizeInBytes != 0)
    allSegments++;
  capacity = allSegments * segmentSizeInBytes;
  try {
    address = UNSAFE.reallocateMemory(address, capacity);
  } catch (OutOfMemoryError err) {
    throw new OutOfMemoryError(err.getMessage() + " - problem when allocating new memory. Old capacity: "
        + oldCap + ", new bytes:" + newBytes + ", segmentSizeIntsPower:" + segmentSizePower);
  }
  if (clearNewMem)
    UNSAFE.setMemory(address + oldCap, capacity - oldCap, (byte) 0);
  return true;
}

代码示例来源:origin: jdamcd/android-crop

setResultException(e);
} catch (OutOfMemoryError e) {
  Log.e("OOM reading image: " + e.getMessage(), e);
  setResultException(e);
} finally {

代码示例来源:origin: jdamcd/android-crop

setResultException(e);
} catch (OutOfMemoryError e) {
  Log.e("OOM cropping image: " + e.getMessage(), e);
  setResultException(e);
} finally {

代码示例来源:origin: kairosdb/kairosdb

return setHeaders(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new ErrorResponse(e.getMessage()))).build();

代码示例来源:origin: Alluxio/alluxio

/**
 * {@link BufferUtils#cleanDirectBuffer(ByteBuffer)} forces to unmap an unused direct buffer.
 * This test repeated allocates and de-allocates a direct buffer of size 16MB to make sure
 * cleanDirectBuffer is doing its job. The bufferArray is used to store references to the direct
 * buffers so that they won't get garbage collected automatically. It has been tested that if the
 * call to cleanDirectBuffer is removed, this test will fail.
 */
@Test
public void cleanDirectBuffer() {
 final int MAX_ITERATIONS = 1024;
 final int BUFFER_SIZE = 16 * 1024 * 1024;
 // bufferArray keeps reference to each buffer to avoid auto GC
 ByteBuffer[] bufferArray = new ByteBuffer[MAX_ITERATIONS];
 try {
  for (int i = 0; i < MAX_ITERATIONS; i++) {
   ByteBuffer buf = ByteBuffer.allocateDirect(BUFFER_SIZE);
   bufferArray[i] = buf;
   BufferUtils.cleanDirectBuffer(buf);
  }
 } catch (OutOfMemoryError ooe) {
  Assert.fail("cleanDirectBuffer is causing memory leak." + ooe.getMessage());
 }
}

代码示例来源:origin: TakahikoKawasaki/nv-websocket-client

throw new WebSocketException(
  WebSocketError.INSUFFICIENT_MEMORY_FOR_PAYLOAD,
  "OutOfMemoryError occurred during a trial to allocate a memory area for a frame's payload: " + e.getMessage(), e);

代码示例来源:origin: facebook/stetho

response.error = mObjectMapper.convertValue(e.getMessage(), JSONObject.class);
jsonObject = mObjectMapper.convertValue(response, JSONObject.class);
responseString = jsonObject.toString();

代码示例来源:origin: h2oai/h2o-2

throw H2O.setDetailMessage(re,re.getMessage()+" while mapping key "+_keys[_lo]);
} catch( OutOfMemoryError re ) { // Catch user-map-thrown exceptions
 throw H2O.setDetailMessage(re,re.getMessage()+" while mapping key "+_keys[_lo]);

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testErrorThrownByCallback() throws Exception {
  callback = new RepeatCallback() {
    private volatile AtomicInteger count = new AtomicInteger(0);
    @Override
    public RepeatStatus doInIteration(RepeatContext context)
        throws Exception {
      int position = count.incrementAndGet();
      
      if(position == 4) {
        throw new OutOfMemoryError("Planned");
      }
      else {
        return RepeatStatus.CONTINUABLE;
      }
    }
  };
  
  template.setCompletionPolicy(new SimpleCompletionPolicy(10));
  try {
    template.iterate(callback);
    fail("Expected planned exception");
  } catch (OutOfMemoryError oome) {
    assertEquals("Planned", oome.getMessage());
  } catch (Exception e) {
    e.printStackTrace();
    fail("Wrong exception was thrown: " + e);
  }
}

相关文章