Quantcast
Channel: 質問!ITmedia 新着質問(Java/253)
Viewing all articles
Browse latest Browse all 2439

javaのOutOfMemoryErrorエラー

$
0
0
毎度お世話になります。 void writeSync_Nword(DeviceHandle handle, int[] wordxxx)なるサブルーチンを 実行しますと、約500回に1回程度、下記の如く”OutOfMemoryError"エラーが発生します。 Q1)このエラーの対策につきまして、お教え頂けないでしょうか? Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Direct buffer memory at java.nio.Bits.reserveMemory(Bits.java:658) at java.nio.DirectByteBuffer.(DirectByteBuffer.java:123) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) at org.usb4java.BufferUtils.allocateByteBuffer(BufferUtils.java:44) at FUNC_test.writeSync_Nword(FUNC_test.java:100) //============================================== public static void writeSync_Nword(DeviceHandle handle, int[] wordxxx){ byte[] data=int2ByteN(wordxxx); //little_endianでbyteに変換 ByteBuffer buffer = BufferUtils.allocateByteBuffer(data.length); //<---ここでエラー発生 buffer.put(data); IntBuffer transferred=BufferUtils.allocateIntBuffer(); int result=LibUsb.bulkTransfer(handle, EP_OUTcmd, buffer, transferred, TIMEOUT); if (result != LibUsb.SUCCESS){ throw new LibUsbException("Unable to execute writeSync_Nword", result); } } //=========================== public static byte[] int2ByteN(int word[]){ int n_word=word.length; ByteBuffer byteBuffer=ByteBuffer.allocate(Integer.SIZE/Byte.SIZE*n_word); byteBuffer.order(ByteOrder.LITTLE_ENDIAN); for(int i=0; i

Viewing all articles
Browse latest Browse all 2439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>