我用的是Apache httpasyncclient 4.1,在jconsole中发现直接内存一直在增长,我试过force gc,不行。
让我感到困惑的是我不使用 DirectByteBufferAllocator。
ManagedNHttpClientConnectionFactory connFactory = new ManagedNHttpClientConnectionFactory(null,
null, HeapByteBufferAllocator.INSTANCE);
connManager = new PoolingNHttpClientConnectionManager(ioreactor, connFactory,
socketFactoryRegistry, new DNSResolverWithCache(dnsCache));
我也grep了httpclient httpasynclient httpcore httpcore-nio的源码,只是在DirectByteBufferAllocator中有方法allocateDirect(1024)。