-
Notifications
You must be signed in to change notification settings - Fork 60
problem with PooledMemoryManager #1938
Comments
@kentsang77 You're aware how to change the default memory manager back to HeapMemoryManager? |
Try start jvm with
option |
The root of the issue is that with allocations that span multiple buffers, as is the case with the large allocation, the ByteBuffer you obtain from the Buffer isn't shared between the two. The documentation for Buffer.toByteBuffer() states:
I have a question about the test case. You do the following: ` final Buffer output = memoryManager.allocate(allocationSize);
` Is there a reason you're converting to a ByteBuffer prior to manipulating? Was this only to demonstrate the problem or do you do this in production? |
It is currently doing at production. |
Then the option you have is a) Set the default memory manager to HeapMemoryManager or b) if the Buffer is composite, copy the ByteBuffer content back to the Buffer. The latter option isn't ideal for performance reasons. |
My solution is to use a PooledMemoryManagerFactory to init a PooledMemoryManager with large enough DEFAULT_BASE_BUFFER_SIZE (where allocationSize < DEFAULT_BASE_BUFFER_SIZE ). Personally I think if the PooledMemoryManager cannot handle large buffer size, it should throw exception. At least not just returning a weired empty buffer. |
I have used HeapMemoryManager for a long time and everything works fine.
Last week we tried grizzly version 2.3.30 and found that message decoder doesn't work at all.
Last working grizzly version was 2.3.24.
After investigation, we found the default MemoryManager changed to PooledMemoryManager at 2.3.26 and there is a strange issue when allocating a large encoding buffer (say 4M):
The symptom is : only null bytes can be read at decoder.
I created a all in 1 class junit for your investigation.
StringMessageFilterTest.zip
The text was updated successfully, but these errors were encountered: