BZ #55: Azureus throws java.lang.OutOfMemoryError: Direct buffer memory

Status fields:

creation_ts:2008-03-25 08:06
component:vm
version:default branch
rep_platform:All
op_sys:Linux
bug_status:RESOLVED
resolution:LATER
reporter:twisti@complang.tuwien.ac.at
This happens with IcedTea6 b06 after running some hours.

DEBUG::Tue Mar 25 00:04:42 CET
2008::org.gudy.azureus2.core3.util.DirectByteBufferPool::allocateNewBuffer::206:
  Memory allocation failed: Out of direct memory space.
To fix: Use the -XX:MaxDirectMemorySize=512m command line option,
or upgrade your Java JRE to version 1.4.2_05 or 1.5 series or newer.
    DirectByteBufferPool::getBufferHelper::287,DirectByteBufferPool::getBuffer::237,BTMe
ssageDecoder::postReadProcess::363,BTMessageDecoder::performStreamDecode::108,IncomingMe
ssageQueueImpl::receiveFromTransport::112,SinglePeerDownloader::doProcessing::76,ReadCon
troller::doRead::293,ReadController::doNormalPriorityRead::247,ReadController::readProce
ssorLoop::228,ReadController::access$200::43,ReadController$2::runSupport::88,AEThread::
run::71
[alert] Alert:3:Memory allocation failed: Out of direct memory space.
To fix: Use the -XX:MaxDirectMemorySize=512m command line option,
or upgrade your Java JRE to version 1.4.2_05 or 1.5 series or newer.
DEBUG::Tue Mar 25 00:04:42 CET 2008::com.aelitis.azureus.core.networkmanager.impl.Single
PeerDownloader::doProcessing::97:
  java.lang.OutOfMemoryError: Direct buffer memory
        at java.nio.Bits.reserveMemory(Bits.java:656)
        at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:113)
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:305)
        at org.gudy.azureus2.core3.util.DirectByteBufferPool.allocateNewBuffer(DirectByt
eBufferPool.java:199)
        at org.gudy.azureus2.core3.util.DirectByteBufferPool.getBufferHelper(DirectByteB
ufferPool.java:287)
        at org.gudy.azureus2.core3.util.DirectByteBufferPool.getBuffer(DirectByteBufferP
ool.java:237)
        at com.aelitis.azureus.core.peermanager.messaging.bittorrent.BTMessageDecoder.po
stReadProcess(BTMessageDecoder.java:363)
        at com.aelitis.azureus.core.peermanager.messaging.bittorrent.BTMessageDecoder.pe
rformStreamDecode(BTMessageDecoder.java:108)
        at com.aelitis.azureus.core.networkmanager.impl.IncomingMessageQueueImpl.receive
FromTransport(IncomingMessageQueueImpl.java:112)
        at com.aelitis.azureus.core.networkmanager.impl.SinglePeerDownloader.doProcessin
g(SinglePeerDownloader.java:76)
        at com.aelitis.azureus.core.networkmanager.impl.ReadController.doRead(ReadContro
ller.java:293)
        at com.aelitis.azureus.core.networkmanager.impl.ReadController.doNormalPriorityR
ead(ReadController.java:247)
        at com.aelitis.azureus.core.networkmanager.impl.ReadController.readProcessorLoop
(ReadController.java:228)
        at com.aelitis.azureus.core.networkmanager.impl.ReadController.access$200(ReadCo
ntroller.java:43)
        at com.aelitis.azureus.core.networkmanager.impl.ReadController$2.runSupport(Read
Controller.java:88)
        at org.gudy.azureus2.core3.util.AEThread.run(AEThread.java:71)

Comment #1 by twisti@complang.tuwien.ac.at on 2008-03-27 11:43:47

This changeset should fix the bug:

http://mips.complang.tuwien.ac.at/hg/cacao/rev/bd1fba089d84

Will try later if it really works.

Comment #2 by twisti@complang.tuwien.ac.at on 2008-03-28 11:00:08

No, the OOM still happens, but later.  The default maximum direct memory size is 64MB
and the Azureus start script sets the maximum heap size, which is then used for the
maxiumum direct memory size, to 128MB.

A bug in freeing direct memory?

Comment #3 by stefan@complang.tuwien.ac.at on 2010-05-18 20:14:51

I guess the problem is that direct buffer cleanup requires phantom references to work
(via sun.misc.Cleaner). Apparently CACAO cannot do this with Boehm.