本文整理了Java中java.lang.OutOfMemoryError.initCause()
方法的一些代码示例,展示了OutOfMemoryError.initCause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutOfMemoryError.initCause()
方法的具体详情如下:
包路径:java.lang.OutOfMemoryError
类名称:OutOfMemoryError
方法名:initCause
暂无
代码示例来源:origin: redisson/redisson
/**
* Increase the storage of this {@link KQueueEventArray}.
*/
void realloc(boolean throwIfFail) {
// Double the capacity while it is "sufficiently small", and otherwise increase by 50%.
int newLength = capacity <= 65536 ? capacity << 1 : capacity + capacity >> 1;
try {
ByteBuffer buffer = Buffer.allocateDirectWithNativeOrder(calculateBufferCapacity(newLength));
// Copy over the old content of the memory and reset the position as we always act on the buffer as if
// the position was never increased.
memory.position(0).limit(size);
buffer.put(memory);
buffer.position(0);
Buffer.free(memory);
memory = buffer;
memoryAddress = Buffer.memoryAddress(buffer);
} catch (OutOfMemoryError e) {
if (throwIfFail) {
OutOfMemoryError error = new OutOfMemoryError(
"unable to allocate " + newLength + " new bytes! Existing capacity is: " + capacity);
error.initCause(e);
throw error;
}
}
}
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code bool} array of the given size.
*
* @param size the number of {@code bool} elements to allocate
*/
public BoolPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new BoolPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code double} array of the given size.
*
* @param size the number of {@code double} elements to allocate
*/
public DoublePointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new DoublePointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code boolean} array of the given size.
*
* @param size the number of {@code boolean} elements to allocate
*/
public BooleanPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new BooleanPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native array of {@code void*} of the given size.
*
* @param size the number of {@code void*} elements to allocate
*/
public PointerPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new PointerPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code short} array of the given size.
*
* @param size the number of {@code short} elements to allocate
*/
public ShortPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new ShortPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code long long} array of the given size.
*
* @param size the number of {@code long long} elements to allocate
*/
public LongPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new LongPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code float} array of the given size.
*
* @param size the number of {@code float} elements to allocate
*/
public FloatPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new FloatPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code short} array of the given size.
*
* @param size the number of {@code short} elements to allocate
*/
public CharPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new CharPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code size_t} array of the given size.
*
* @param size the number of {@code size_t} elements to allocate
*/
public SizeTPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new SizeTPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code long} array of the given size.
*
* @param size the number of {@code long} elements to allocate
*/
public CLongPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new CLongPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code signed char} array of the given size.
*
* @param size the number of {@code signed char} elements to allocate
*/
public BytePointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new BytePointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: bytedeco/javacpp
/**
* Allocates a native {@code int} array of the given size.
*
* @param size the number of {@code int} elements to allocate
*/
public IntPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new IntPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: robolectric/robolectric
@Implementation
protected static long nativeLoad(String java_path, boolean system,
boolean force_shared_lib, boolean overlay) throws IOException {
String path = java_path;
if (path == null) {
return 0;
}
ATRACE_NAME(String.format("LoadApkAssets(%s)", path));
CppApkAssets apk_assets;
try {
if (overlay) {
apk_assets = CppApkAssets.LoadOverlay(path, system);
} else if (force_shared_lib) {
apk_assets =
CppApkAssets.LoadAsSharedLibrary(path, system);
} else {
apk_assets = CppApkAssets.Load(path, system);
}
} catch (OutOfMemoryError e) {
OutOfMemoryError outOfMemoryError = new OutOfMemoryError("Failed to load " + path);
outOfMemoryError.initCause(e);
throw outOfMemoryError;
}
if (apk_assets == null) {
String error_msg = String.format("Failed to load asset path %s", path);
throw new IOException(error_msg);
}
return Registries.NATIVE_APK_ASSETS_REGISTRY.register(apk_assets);
}
代码示例来源:origin: com.bugvm/javacpp
/**
* Allocates a native {@code long long} array of the given size.
*
* @param size the number of {@code long long} elements to allocate
*/
public LongPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new LongPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: com.bugvm/javacpp
/**
* Allocates a native {@code double} array of the given size.
*
* @param size the number of {@code double} elements to allocate
*/
public DoublePointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new DoublePointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: com.bugvm/javacpp
/**
* Allocates a native {@code signed char} array of the given size.
*
* @param size the number of {@code signed char} elements to allocate
*/
public BytePointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new BytePointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: com.bugvm/javacpp
/**
* Allocates a native {@code short} array of the given size.
*
* @param size the number of {@code short} elements to allocate
*/
public ShortPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new ShortPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: com.bugvm/javacpp
/**
* Allocates a native {@code size_t} array of the given size.
*
* @param size the number of {@code size_t} elements to allocate
*/
public SizeTPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new SizeTPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
代码示例来源:origin: com.bugvm/javacpp
/**
* Allocates a native array of {@code void*} of the given size.
*
* @param size the number of {@code void*} elements to allocate
*/
public PointerPointer(long size) {
try {
allocateArray(size);
if (size > 0 && address == 0) {
throw new OutOfMemoryError("Native allocator returned address == 0");
}
} catch (UnsatisfiedLinkError e) {
throw new RuntimeException("No native JavaCPP library in memory. (Has Loader.load() been called?)", e);
} catch (OutOfMemoryError e) {
OutOfMemoryError e2 = new OutOfMemoryError("Cannot allocate new PointerPointer(" + size + "): "
+ "totalBytes = " + formatBytes(totalBytes()) + ", physicalBytes = " + formatBytes(physicalBytes()));
e2.initCause(e);
throw e2;
}
}
/** @see Pointer#Pointer() */
内容来源于网络,如有侵权,请联系作者删除!