ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prashant312 <p.ve...@crif.com>
Subject Re: Apache heap getting increase with cacheConfig.setCopyOnRead as false
Date Sun, 02 Jul 2017 03:54:52 GMT
Hi,

Please find below my code for creating and populating cache.

----

package ignite;


import java.util.Arrays;

import javax.cache.configuration.Factory;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import
org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;

public class PopulateCache {

    public static IgniteCache<String, String> igniteCache=null;


    public static void main(String[] args) {


		
        Ignition.setClientMode(false);
    	
    	System.setProperty(IgniteSystemProperties.IGNITE_QUIET,"false");
    	System.setProperty("java.net.preferIPv4Stack" , "true");
    	

        TcpDiscoverySpi spi = new TcpDiscoverySpi();
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
        ipFinder.setAddresses(Arrays.asList("localhost",
"localhost:47500..47509"));
        spi.setIpFinder(ipFinder);

        IgniteConfiguration cfg = new IgniteConfiguration();

        cfg.setDiscoverySpi(spi);

        Ignite ignite = Ignition.start(cfg);


        CacheConfiguration<String, String> cacheConfig=new
CacheConfiguration<String, String>();

        cacheConfig.setBackups(1);
        cacheConfig.setCopyOnRead(false);

        cacheConfig.setName("testCache");
        cacheConfig.setCacheMode(CacheMode.PARTITIONED);

        igniteCache=ignite.getOrCreateCache(cacheConfig);

        igniteCache.put("100", "abc");

        System.out.println("Done....cache");
    }

    public static Object getCacheData(String key){

        if(igniteCache!=null){
            return igniteCache.get(key);
        }
        return key;
    }

}
-------------------------------------------------------

Log - 
/
You can find that during creation of cache where we are putting just one
value heap is 1.8 Gb.

Topology snapshot [ver=1, servers=1, clients=0, CPUs=4, heap=1.8GB]
/
Now code for getting the cache is below
------------------------------------------------------

package ignite;

import java.util.Arrays;
import java.util.Properties;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import
org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import static
org.apache.ignite.IgniteSystemProperties.IGNITE_REST_START_ON_CLIENT;


public class StartIgnite {

    public static IgniteCache<String, String> igniteCache=null;

    public static void startIgnite(){


        Ignition.setClientMode(true);
        System.setProperty(IgniteSystemProperties.IGNITE_QUIET,"false");
		
        TcpDiscoverySpi spi = new TcpDiscoverySpi();
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
        ipFinder.setAddresses(Arrays.asList("localhost",
"localhost:47500..47509"));
        spi.setIpFinder(ipFinder);
        System.out.println(ipFinder);

        IgniteConfiguration cfg = new IgniteConfiguration();

        cfg.setDiscoverySpi(spi);

        Ignite ignite = Ignition.start(cfg);

        CacheConfiguration<String, String> cacheConfig=new
CacheConfiguration<String, String>();
        cacheConfig.setName("testCache");
        cacheConfig.setCopyOnRead(false);
        //cacheConfig.
        //cacheConfig.s
        cacheConfig.setAtomicityMode(CacheAtomicityMode.ATOMIC);
        igniteCache=ignite.getOrCreateCache(cacheConfig);
        System.out.println("cache name is "+ igniteCache.getName());

    }

    public static void stopIgnite(){
        Ignition.stop(true);
    }

    public static String getCacheData(String id){

        return igniteCache.get(id);
    }

    public static void main(String[] args) {

        startIgnite();
       
//System.out.println(Cache.getCacheData(CacheConstants.CLEANSING_TOKENS));

        String obj=igniteCache.get("200");
        String obj2=igniteCache.get("100");
        System.out.println(obj);
        System.out.println(obj2);

        stopIgnite();

    }

}
--------------------------------------------------

When we are executing above code heap gets increased to 3.5 GB.

09:22:55] Topology snapshot [ver=2, servers=1, clients=1, CPUs=4,
heap=3.5GB]
[09:22:57] Topology snapshot [ver=3, servers=1, clients=0, CPUs=4,
heap=1.8GB]

We want to avoid increase in heap size, in production we have cache of
around 30 Gb and we are running the process parallel, causing heap size
full.

Thanks,
Prashant 



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Apache-heap-getting-increase-with-cacheConfig-setCopyOnRead-as-false-tp14175p14228.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message