3 Replies Latest reply on Oct 11, 2010 6:01 AM by Nhut nhutn

    I have memory problem with Infinispan

    Nhut nhutn Newbie

      Today, I have a test to choose which java cache system. with Infinispan I put 100000 items<key type:Long,value type: User Object>.User Object has(userid:Long,name:String,list<long>:friend). And I have result:


      put  100000 items memory used: 50MB.Then,  take all item: memory used:150MB.


      Why they are big different.My  own map cache when put these items is 250MB and it still 250MB when I take all item from cache.

        • 1. Re: I have memory problem with Infinispan
          Nhut nhutn Newbie

          So this is my test code:

          public static void main(String... s) throws Exception {
                  EmbeddedCacheManager manager = new DefaultCacheManager();
                  Cache<Integer,User> cache = manager.getCache();
                  List<Long> listFriend = new ArrayList<Long>();
                  for (int k = 0; k < 100; k++) {
                      listFriend.add(new Long(k));
                  for (int i = 0; i < 100000; i++) {
                      User u = new User(i, "helo woels dsf jlsdjkf klsd jlkdsfj kldskdlsf jdkls jlds fjkldsfjdklfsjklds jkl lkdjfl");
                      cache.put(i, u);
                  System.out.println("set cache ok");
                  for(int h=0;h<5;h++){
                  for (int i = 0; i < 100000; i++) {

          • 2. Re: I have memory problem with Infinispan
            Mircea Markus Master

            Hi Nhut,


            On reading additional objects are being created on reading objects from the cache: thats's just part of Infinsipan's internals e.g. they have to do with supporting different isolation levels etc. These object should be collected by the GC though. What map do you use for caching? Seems like infinsipan's memory usage is better. 

            • 3. Re: I have memory problem with Infinispan
              Nhut nhutn Newbie

              Thank Markus,

              I think it is all with GC.because after I take all items, the memory used be decreased.My Current Map I used is com.reardencommerce.kernel.collections.shared.evictable.ConcurrentLinkedHashMap, It work OK but take more memory( although I serializer Object to byte arrays).

              Thanks for your helpful.