[ 
https://issues.apache.org/jira/browse/DIRECTMEMORY-118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13532341#comment-13532341
 ] 

Prashant Sharma commented on DIRECTMEMORY-118:
----------------------------------------------

Please see the following diff that fixes the problem.

{noformat}
Index: 
directmemory-cache/src/main/java/org/apache/directmemory/memory/allocator/MergingByteBufferAllocatorImpl.java
===================================================================
--- 
directmemory-cache/src/main/java/org/apache/directmemory/memory/allocator/MergingByteBufferAllocatorImpl.java
       (revision 1421100)
+++ 
directmemory-cache/src/main/java/org/apache/directmemory/memory/allocator/MergingByteBufferAllocatorImpl.java
       (working copy)
@@ -136,12 +136,12 @@
     {
         List<Integer> sizes = new ArrayList<Integer>();
 
-        for ( int i = minSizeThreshold; i <= totalSize; i *= 8 )
+        for ( Long i = Integer.valueOf(minSizeThreshold).longValue(); i <= 
totalSize.longValue(); i *= 8 )
         {
-            sizes.add( Integer.valueOf( i ) );
+            sizes.add( i.intValue() );
         }
 
-        // If totalSize < minSizeThreshold or totalSize is not a multiple of 
minSizeThreshold 
+        // If totalSize < minSizeThreshold or totalSize is not a multiple of 
minSizeThreshold
         // we force adding an element to the map
         if ( sizes.isEmpty() || !sizes.contains( totalSize ) )
         {
{noformat}
                
> MemoryManager crashes on allocation of more than 300Mb or memory
> ----------------------------------------------------------------
>
>                 Key: DIRECTMEMORY-118
>                 URL: https://issues.apache.org/jira/browse/DIRECTMEMORY-118
>             Project: Apache DirectMemory
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 0.2
>            Reporter: Prashant Sharma
>             Fix For: 0.2
>
>
> Following code reproduces the bug.
> val cacheService =  new DirectMemory[String, ArrayBuffer[Any]]()
>     .setNumberOfBuffers(1)
>     .setInitialCapacity(1)
>     .setMemoryManager(new MemoryManagerServiceImpl(true))
>     .setSize(300 *(1024*1024))
>     .setConcurrencyLevel(1)
>     .newCacheService();

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to