Exemplo n.º 1
0
        private ImageCache(int maxCacheSize)
		{
			int safeMaxCacheSize = GetMaxCacheSize(maxCacheSize);

			// consider low treshold as a third of maxCacheSize
			int lowTreshold = safeMaxCacheSize / 3;

			_cache = new ReuseBitmapDrawableCache(safeMaxCacheSize, lowTreshold, safeMaxCacheSize);
		}
Exemplo n.º 2
0
 BitmapCache(Context ctx, DiskCache diskCache, bool useRoundCorners)
 {
     this.context = ctx;
     this.useRoundCorners = useRoundCorners;
     this.diskCache = diskCache;
     var highWatermark = Java.Lang.Runtime.GetRuntime().MaxMemory() / 3;
     var lowWatermark = highWatermark / 2;
     this.memCache = new ReuseBitmapDrawableCache (highWatermark, lowWatermark, highWatermark);
 }
Exemplo n.º 3
0
        BitmapCache(Context ctx, DiskCache diskCache, bool useRoundCorners)
        {
            this.context         = ctx;
            this.useRoundCorners = useRoundCorners;
            this.diskCache       = diskCache;
            var highWatermark = Java.Lang.Runtime.GetRuntime().MaxMemory() / 3;
            var lowWatermark  = highWatermark / 2;

            this.memCache = new ReuseBitmapDrawableCache(highWatermark, lowWatermark, highWatermark);
        }
Exemplo n.º 4
0
        private ImageCache(int maxCacheSize, IMiniLogger logger, bool verboseLogging)
        {
            _logger = logger;
            int safeMaxCacheSize = GetMaxCacheSize(maxCacheSize);

            // consider low treshold as a third of maxCacheSize
            int lowTreshold = safeMaxCacheSize / 3;

            _cache = new ReuseBitmapDrawableCache(logger, safeMaxCacheSize, lowTreshold, safeMaxCacheSize, verboseLogging);
            _imageInformations = new ConcurrentDictionary<string, ImageInformation>();
        }
Exemplo n.º 5
0
        private ImageCache(int maxCacheSize, IMiniLogger logger, bool verboseLogging)
		{
			_logger = logger;
			int safeMaxCacheSize = GetMaxCacheSize(maxCacheSize);

            double sizeInMB = Math.Round(safeMaxCacheSize / 1024d / 1024d, 2);
            logger.Debug(string.Format("Image memory cache size: {0} MB", sizeInMB));

			// consider low treshold as a third of maxCacheSize
			int lowTreshold = safeMaxCacheSize / 3;

			_cache = new ReuseBitmapDrawableCache(logger, safeMaxCacheSize, lowTreshold, safeMaxCacheSize, verboseLogging);
			_imageInformations = new ConcurrentDictionary<string, ImageInformation>();
		}
Exemplo n.º 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var highWatermark = Java.Lang.Runtime.GetRuntime().MaxMemory() / 3;
            var lowWatermark = highWatermark / 2;

            // The GC threshold is the amount of bytes that have been evicted from the cache
            // that will trigger a GC.Collect. For example if set to 2mb, a GC will be performed
            // each time the cache has evicted a total of 2mb.
            // This means that we can have highWatermark + gcThreshold amount of memory in use
            // before a GC is forced, so we should ensure that the threshold value + hightWatermark
            // is less than our total memory.
            // In our case, the highWatermark is 1/3 of max memory, so using the same value for the
            // GC threshold means we can have up to 2/3 of max memory in use before kicking the GC.
            var gcThreshold = highWatermark;

            image_cache = new ReuseBitmapDrawableCache(highWatermark, lowWatermark, gcThreshold);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            ThreadPool.QueueUserWorkItem(DownloadImages);
        }
Exemplo n.º 7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var highWatermark = Java.Lang.Runtime.GetRuntime().MaxMemory() / 3;
            var lowWatermark  = highWatermark / 2;

            // The GC threshold is the amount of bytes that have been evicted from the cache
            // that will trigger a GC.Collect. For example if set to 2mb, a GC will be performed
            // each time the cache has evicted a total of 2mb.
            // This means that we can have highWatermark + gcThreshold amount of memory in use
            // before a GC is forced, so we should ensure that the threshold value + hightWatermark
            // is less than our total memory.
            // In our case, the highWatermark is 1/3 of max memory, so using the same value for the
            // GC threshold means we can have up to 2/3 of max memory in use before kicking the GC.
            var gcThreshold = highWatermark;

            image_cache = new ReuseBitmapDrawableCache(highWatermark, lowWatermark, gcThreshold);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            ThreadPool.QueueUserWorkItem(DownloadImages);
        }